Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Question Unanswered: Passing option box choices to a report

    Hi everyone,

    I have something that I can't seem to really get to working. On my form I have an OptionBox with 7 options. When I make a choice in the OptionBox the Form filters to reflect that with this code:

    Code:
    Private Sub TypeOptions_AfterUpdate()
    
    If TypeOptions = 1 Then
            Me.Filter = "Type = 'Youth'"
            Me.FilterOn = True
        ElseIf TypeOptions = 2 Then
            Me.Filter = "Type = 'Elderly'"
            Me.FilterOn = True
        ElseIf TypeOptions = 3 Then
            Me.Filter = "Type = 'Animals'"
            Me.FilterOn = True
        ElseIf TypeOptions = 4 Then
            Me.Filter = "Type = 'SocSvc'"
            Me.FilterOn = True
        ElseIf TypeOptions = 5 Then
            Me.Filter = "Type = 'Work'"
            Me.FilterOn = True
        ElseIf TypeOptions = 6 Then
            Me.Filter = "Type = 'SpecEvents'"
        Else
            Me.FilterOn = False
          End If
        
    
    End Sub
    Yet when I click on the CommandButton on the form that opens the report I get a Prompt, just as with a ParameterQuery, only I'm not using one saying "Enter Parameter Value", TypeOptions. At the same time that window pops up the report is opened showing All Data and is in the background until I enter something in that window, which does nothing.
    I need to know how to get the choice I make in the OptionBox to work for the Report as it does in the Form.

    thanks in advance for any help,
    BUD

  2. #2
    Join Date
    Nov 2005
    Posts
    113
    I think you can try this:

    Code:
    Private Sub cmdRapport_Click()
    Dim strFilter as String
    
        If TypeOptions = 1 Then
            strFilter  = "Youth"
        ElseIf TypeOptions = 2 Then
            strFilter  = "Elderly"
        ElseIf TypeOptions = 3 Then
           strFilter  = "Animals"
        ElseIf TypeOptions = 4 Then
            strFilter  = "SocSvc"
        ElseIf TypeOptions = 5 Then
            strFilter  = "Work"
        ElseIf TypeOptions = 6 Then
            strFilter  = "SpecEvents"
        Else
            Msgbox "Something is wrong "
            Exit sub
        End If
      
    DoCmd.OpenReport  "rptYoursRepport" ,acPreview, , " [Type] like" &  "'" & srtFilter &  "'"  
    
    End Sub
    Last edited by Julita; 02-18-07 at 10:53.

  3. #3
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Talking

    [QUOTE=Julita]Thanks Julita, I will give this a try when I get home tonight.

    BUD

Posting Permissions

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