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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Report with where clause

Status
Not open for further replies.

Cloonalt

Programmer
Jan 4, 2003
354
0
0
US
Seems to me that this should work but doesn't:

Dim stDocName As String
stDocName = "rptInvoice"
DoCmd.OpenReport stDocName, acPreview, , [InvoiceID] = [Forms]![frmPaymentInvoice]![InvoiceID]


It retrieves all records, instead of the invoiceID on the form.

InvoiceID is also a field in the query that the report is based on and is displayed on the report.

Any help appreciated. Thanks.
 
Use
Code:
DoCmd.OpenReport stDocName, acPreview, , "InvoiceID = '" & [Forms("frmPaymentInvoice").InvoiceID & "'"
 
That's because it treats "INVOICEID" as variable, not as field. You need to enclose the criteria in quotes:
Code:
DoCmd.OpenReport stDocName, acPreview, , "[InvoiceID] = [Forms]![frmPaymentInvoice]![InvoiceID]"

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top