Combo Box Selection to Filter Report

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!!!
 
A

Allen Browne

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!!!
 
K

kietvt

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!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top