Combo Box Selection to Filter Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a combo box that pulls from a table. Once a selection is chosen, I need a filtered report to open based on the selection from the combo box. I don't know Visual Basic, so I'm trying to do this through a macro, but it's not working. There Where Condiition of the macro states, "[Account]=[Forms]![Menu]![AccountListing]". Account is the name of the field in the drop down box. AccountListing is the name of the combo box, which is in a form named Menu. Any suggestions would be GREATLY appreciated!!!
 
1. Place a command button on your form, for opening the report.

2. Right-click the command button, and choose Properties.

3. Set the On Click property to:
[Event Procedure]

4. Click the Build button (...) beside this.
Access opens the code window.

5. Between the "Private Sub..." and "End Sub" lines, paste:

Dim strWhere As String
strWhere = "[Account] = " & Me.[AccountListing]
DoCmd.OpenReport "NameOfYourReport", acViewPreview, , strWhere


Note: If Account is a field of the Text, you need extra quotes:
strWhere = "[Account] = """ & Me.[AccountListing] & """"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

amheppe said:
I've created a combo box that pulls from a table. Once a selection is
chosen, I need a filtered report to open based on the selection from the
combo box. I don't know Visual Basic, so I'm trying to do this through a
macro, but it's not working. There Where Condiition of the macro states,
"[Account]=[Forms]![Menu]![AccountListing]". Account is the name of the
field in the drop down box. AccountListing is the name of the combo box,
which is in a form named Menu. Any suggestions would be GREATLY
appreciated!!!
 
Hi,

Could you try this solution:
+ Open your report in the design view
+ Go to property then record source
+ Click to ... record source
+ Then the program will open the "querry builder"
+ Write the statement at the combo box's source:
Forms!"your form name containing the combobox"!"name of
combobox"

I wish this should be OK



-----Original Message-----
I've created a combo box that pulls from a table. Once a
selection is chosen, I need a filtered report to open
based on the selection from the combo box. I don't know
Visual Basic, so I'm trying to do this through a macro,
but it's not working. There Where Condiition of the macro
states, "[Account]=[Forms]![Menu]![AccountListing]".
Account is the name of the field in the drop down box.
AccountListing is the name of the combo box, which is in a
form named Menu. Any suggestions would be GREATLY
appreciated!!!
 
Back
Top