Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter report by selection 1

Status
Not open for further replies.

barcode711

Technical User
Jan 9, 2002
13
US
I want to create a form that has a combo box or listbox that allows for the user to select what data and from which month to print a report.

The user is going to select the data to view(they will choose from 15 different liquid levels), and then choose the Month. (I may want to add year as well later on) I have one table, and one query: tblData , and qryGetData .

On tblData,fldDataType I created a combo box with a list of all the values that should used(15). On my query I have a field with this expression: Month:Format([fldEntryDate],"mmmm")-this changes entry date to months. I created parameter prompts to type in the month and dataype they want to view in a report.

When I run the report this way, I get the reports for each individual datatype fine, but prefer not to have to user type in criteria;would rather have them select from 2 combo boxes.

I'm not the best at coding, and appreciate any help!
 
create two unbound listboxes

set the RowSourceType of lstLiquidLevel to ValueList
set the RowSource of lstLiquidLevel to val1;val2;...val14;val15

set the RowSourceType of lstMonths to table/query
set the rowsource to a query retrieving the month values from your source table only, grouped so each month only shows up once

copy the SQL string behind your query (go to the toolbar and select SQL view from the view drop-down)

paste it into the code behind your "View Report" button like so:

Reports.item("rptYourReportName").recordsource = "SELECT...[rest of SQL statement]"

replace the criteria value segments with variables like this:

WHERE criteria1=" & me.lstLiquidLevel & " AND field2=" & me.lstMonths & ";"

there'll probably be some parenthesis in there too, just remember to user the & charater when splitting the SQL string and inserting your form variable

place this before your docmd.openreport statement



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top