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

Code for printing only one report based on customerID

Status
Not open for further replies.

leaners

Technical User
May 16, 2006
12
AU
what am I doing wrong?

My report is called Booking and my primary ID is called CustomerID. The report is meant to print an invoice specific to the customerID i.e. for the current booking.

The report displays every booking instead of the one specific top the customer. The code is attatched to a button called invoice. Please help.

Code:
Private Sub Invoice_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "Booking"
strWhere = "[CustomerID]=" & Me!CustomerID
DoCmd.OpenReport strDocName, acPreview, strWhere
End Sub
 
Is there any other method for previewing an invoice based on customerID?
 
How are ya leaners . . .

Apparently CustomerID is on [blue]the many side[/blue] of a table. Use the [blue]PrimaryKey[/blue] of the table instead. If you don't have a PK (bad idea in this case) you'll have to [blue]include some other unique field[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
DoCmd.OpenReport strDocName, acPreview, [!],[/!] strWhere

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top