Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Trying to get select case to work with report

I'm using the following code to try to filter results on a report.  Frame 47 is an option group on a the form.  But Case 1 isn't working let alone the rest of them.  Is my syntax wrong?  When the report runs I 'm getting all records instead of the one as 1

Private Sub cmdTaskReport_Click()
On Error GoTo cmdTaskReport_Click_Err

    Select Case Priority

    Case 1
        DoCmd.OpenReport "rptTasks", acViewPreview, , Me.Frame47.Value = 1, acWindowNormal
    Case 2
        'DoCmd.OpenReport "rptTasks", acViewPreview, , [Priority] = 2, acWindowNormal
    Case 3
        'DoCmd.OpenReport "rptTasks", acViewPreview, , [Priority] = 3, acWindowNormal
    Case Else
        DoCmd.OpenReport "rptTasks", acViewPreview, "", "", acNormal

    End Select

cmdTaskReport_Click_Exit:
    Exit Sub

cmdTaskReport_Click_Err:
    MsgBox Error$
    Resume cmdTaskReport_Click_Exit

End Sub
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

how about

  Case 1
        DoCmd.OpenReport "rptTasks", acViewPreview, , [Priority] = 1, acWindowNormal
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or

Private Sub cmdTaskReport_Click()

DoCmd.OpenReport "rptTasks", acViewPreview, , "[Priority]= " & Me.Frame47.Value , acWindowNormal
Avatar of SteveL13

ASKER

Perfect.  Thank you.