|
|
Question : Combo Box & SQL Query Paramaters Into DoCmd Method
|
|
1. I have a combo box on a form: cmb_Payer (form - frmRrpts) 2. I have a SQL query called "qry_Rpts":
SELECT * from tblPayers where payer = (the value from cmb_Payer)
3. I have a report called "PayerRpt", which calls the SQL queryy, and does the reporting from the results of the query.
What is the proper Docmd.openreport method syntax to call the report from a form. Below is the code I have thus far, but I keep getting error messages:
dim qryRpts as string
sql = SELECT * from tblPayers where payer = Forms!frmRpts!cmbPayer
DoCmd.OpenReport "qry_PayorRpt", acViewPreview, , sql
|
Answer : Combo Box & SQL Query Paramaters Into DoCmd Method
|
|
Correct. The "Where Condition" parameter syntax in OpenForm and OpenReport statements is like the where clause of your query --- omitting the WHERE keyword.
With this approach, you can set the criteria for your form/report through the Open statement instead of defining the criteria in the recordsource of the form/report.
|
|
|
|
|