Pass Parameter to Query for Report Generation

kostaskir

Registered User.
Local time
Today, 23:10
Joined
Jan 21, 2009
Messages
65
Hello guys !

I am having a problem with the creation of a dynamic report.

I have a combo box with lots of values , a OK button and a report.

The combo box has to do with music genres (Pop, Rock etc).
I have only one report:


Code:
SELECT CDAll.Artist, CDAll.Title, CDAll.Genre, CDAll.RecordLabel, CDAll.YearReleased, CDAll.Format, CDAll.Rare, CDAll.Tracks, CDAll.Price
FROM Genres INNER JOIN CDAll ON Genres.GenresID=CDAll.Genre
WHERE (((Genres.Genres)=[B][Forms]!Control_Panel.ComboReports))[/B]
ORDER BY CDAll.Artist;
Control_Panel is the Form and ComboReports is the combo box.

When I select a value from the combo, for example "Rock" and I press the OK button :
Code:
Private Sub Preview_Report_Click()
DoCmd.OpenReport "CD Reports", acViewReport
End Sub
The program gives me a message box asking me to write a value.
When I write "Rock" in the message box it brings me the correct result.
Do you know what I have to do to overide this message box ?

I want to pass the value "Rock" in my query in report and to load my report.


Thank you. :D
 
First, try changing the line:
WHERE (((Genres.Genres)=[Forms]!Control_Panel.ComboReports))
to
WHERE (((Genres.Genres)=[Forms]![Control_Panel]![ComboReports]))


It is not clear. How is your "Select" statement being used? If this is just a query on which your report is based then if all else fails, use the "Expression Builder" fromt the QBE to help you get the syntax correct when refering to the control on your form.

Everything else should be fine.
 
It worked !!!

Thank you Mr. B !! :D
 
Your are welcome!

Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom