Button to Open Report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a button to open a report based on the Invoice Number on the
form. THe code looks like this:

Dim stDocName As String
Dim strLocate As String

stDocName = "rptInvoice"
strLocate = "[tblInvoice.lngInvoiceNo]=" & Me.lngInvoiceNo
DoCmd.OpenReport stDocName, acPreview, , strLocate

Trouble is when I click on the button, there is a Enter Parameter Value
dialog box for tblInvoice. It's can't seem to recognize the
[tblInvoice.lngInvoiceNo]. However, if I just click on OK on the EPV dialog
box without entering, the report still opens correctly. Is there something
wrong with the code? Thanks.
ck
 
Good afternoon

Try it this way

DoCmd.OpenReport "rptInvoice", _
WhereCondition:="lngInvoiceNo=" & Me.lngInvoiceNo

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 
Thanks for the tip, Maurice. Trying your suggestion, I got a different error
this time: "the field lngInvoiceNo could refer to more than one table". I
still don't understand why is it asking me to Enter Parameter Value for
tblInvoice when I used [tblInvoice.lngInvoiceNo]. I also tried this form:
[tblInvoice].[lngInvoiceNo] but got the same result. If I remove the
tblInvoice, it will tell me that the field lngInvoiceNo could refer to more
than one table. What am I to do? Thanks.
ck

StCyrM said:
Good afternoon

Try it this way

DoCmd.OpenReport "rptInvoice", _
WhereCondition:="lngInvoiceNo=" & Me.lngInvoiceNo

Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.



I've created a button to open a report based on the Invoice Number on the
form. THe code looks like this:

Dim stDocName As String
Dim strLocate As String

stDocName = "rptInvoice"
strLocate = "[tblInvoice.lngInvoiceNo]=" & Me.lngInvoiceNo
DoCmd.OpenReport stDocName, acPreview, , strLocate

Trouble is when I click on the button, there is a Enter Parameter Value
dialog box for tblInvoice. It's can't seem to recognize the
[tblInvoice.lngInvoiceNo]. However, if I just click on OK on the EPV dialog
box without entering, the report still opens correctly. Is there something
wrong with the code? Thanks.
ck
 
Back
Top