How to generate report based on combo box selection
Hi guys . I created a form that has 3 combo boxes. Their name are Project
Number, year and weekno . It has also a button that on click action supposed
to generate a report baced on my combo box criteria and then loads that report
for me. could any expert show me an example on how to do this. I have difficulty
finding an example in google since i did not exactly what is called this method
of generating report in access 2000.Thanks
Re: How to generate report based on combo box selection
One way:
Create a query to get what you want based on those values, e.g.,
VB Code:
SELECT * FROM tblFoo WHERE fldProj = Forms!frmFoo![Project Number] AND fldNum = Forms!frmFoo![year] AND fldWkNum = Forms!frmFoo![weekno]
and set the report's RecordSource to the query.
You could also do queryDef's & parameters in code.
Re: How to generate report based on combo box selection
Quote:
Originally Posted by salvelinus
One way:
Create a query to get what you want based on those values, e.g.,
VB Code:
SELECT * FROM tblFoo WHERE fldProj = Forms!frmFoo![Project Number] AND fldNum = Forms!frmFoo![year] AND fldWkNum = Forms!frmFoo![weekno]
and set the report's RecordSource to the query.
You could also do queryDef's & parameters in code.
Thank u for u reply. Is this for access 2000 ? where should i place your code?
could u explain allitle more on what to put on click event of the button on the form.Thanks
http://i5.photobucket.com/albums/y18...rojectdata.jpg ( report )
http://i5.photobucket.com/albums/y18...etionship4.jpg ( db tables)
Re: How to generate report based on combo box selection
Yes, Access 2000, and probably any version of Access (97 on, anyway).
Easiest way -
Create & save the query. It won't run by itself, but that's ok. Create the report and set the report's RecordSource property to the query.
In the form, in the Click event of a button put DoCmd.OpenReport "rptFoo" (or whatever your report's name is).
If you want a report in Word or Excel format (looking at your upload), that's a different story. But the above will work for an Access report.