Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    combo box selection (access 97 sr-2)

    I have a combo box on a form based on a table. When the item is selected I want to open a report in preview mode. I am using a select case statement because I have a long list. I am having trouble with the select case. Here is part of my code.

    Private Sub Combo10_AfterUpdate()

    Select Case straward
    Case "Archery Belt Loop"
    DoCmd.OpenReport "rptarchery", acViewPreview
    Case "Badmitton Belt Loop"
    DoCmd.OpenReport "rptbadmitton", acViewPreview
    Case "Baseball belt loop"
    DoCmd.OpenReport "rptbaseball", acViewPreview

    End Select
    End Sub

    I guess I am writing the statement wrong because I can't get it to work. Any help in constructing the select case would be appreciated.
    Thanks,
    Mike

  2. #2
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Emerald Beach, New South Wales, Australia
    Posts
    126
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: combo box selection (access 97 sr-2)

    Mike,

    I'd be tempted to put in a
    Case Else
    msgbox "Unexpected Selection - " & straward
    end select

    this will show you the actual value that you are returning.

    Have you stepped through the code to see what the actiual value that is being returned.

    How many columns has your combo box got and which is the column being returned? I am assuming that straward is the combobox.

    Stewart

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: combo box selection (access 97 sr-2)

    Isn't it "badminton"? Anyhow, assuming that straward is a textbox or a form level variable, you could simplify your code like this:

    Private Sub Combo10_AfterUpdate()
    Dim strRptName as String

    Select Case straward
    Case "Archery Belt Loop"
    strRptName = "rptarchery"
    Case "Badmitton Belt Loop"
    strRptName ="rptbadmitton
    Case "Baseball belt loop"
    strRptName = "rptbaseball"
    Case else
    MsgBox "Unknown value " & straward
    End Select

    DoCmd.OpenReport strRptName, acViewPreview

    End Sub

    If straward is the name of the combobox (instead of Combo10), then the real problem is that the code will never execute because it's in the wrong procedure.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •