How do I use a form to input report criteria?

G

Guest

I am currently using Access 2000.

I am trying to setup a database report using a form. I have created the
unbound form and the report that can pull up all the records from the table I
need. However, I cannot figure out the best expression to use to take the
criteria I enter in the form and use that as the parameters for limiting the
number of records shown.

For example:
(on the form)
Beginning Invoice Date:
Ending Invoice Date:

I am also using other parameters to limit the records show such as those
under a certain vendor or PO#. What expression should I use for these?

Any help would be appreciated.
 
D

Duane Hookom

I recommend using code like:

Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.txtBegInvDate) Then
strWhere = strWhere & " AND [InvoiceDate]>=#" & _
Me.txtBegInvDate & "# "
End If
If Not IsNull(Me.txtEndInvDate) Then
strWhere = strWhere & " AND [InvoiceDate]<=#" & _
Me.txtEmdInvDate & "# "
End If

DoCmd.OpenReport "rptYourRpt", acPreview, , strWhere
 

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