Filtering report based on combo box selection (1 Viewer)

vent

Registered User.
Local time
Yesterday, 22:11
Joined
May 5, 2017
Messages
160
Hey guys,

I have this query that nicely associates and displays information between two tables (tblAgencyInformationNew and tblProgramCodes). I turned this into a report and now working on a form where a user can select an item via dropdown. At first the user can click on a button and the filtered form would pop up however I thought it might be easier to simply use the combo box's onclick property and use a bit of vba. I looked at some previous posts and thought I'd play with some code but so far nothing has worked.

The code here is is the closest I've come and by that I mean when I make a selection I don't get any errors:
Code:
Private Sub cboProgramCodes_Click()
DoCmd.OpenReport "rptAgencyProgramCodes", acViewReport, "[ProgramCode]= '" & [Forms]![frmPrograms]![cboProgramCodes] & "'"
End Sub

The report opens but it displays ALL the records and not the one I selected. Any thoughts?

rptAgencyProgramCodes = report based on AgencyProgramCodes query
ProgramCode = field in query ideally this report should filter by (e.g. *NOCODE, 1213, 3828, etc.)
frmPrograms = form user selects option in combo box
cboProgramCodes = name of combo box
 

Attachments

  • apc.PNG
    apc.PNG
    20.6 KB · Views: 479
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:11
Joined
Aug 30, 2003
Messages
36,124
You have it in the filter position I think, it belongs in the wherecondition position.
 

vent

Registered User.
Local time
Yesterday, 22:11
Joined
May 5, 2017
Messages
160
Thanks guys and Paul you were right. I fixed it now. Thanks!
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:11
Joined
Aug 30, 2003
Messages
36,124
Happy to help!
 

Users who are viewing this thread

Top Bottom