Printing a single Label in Access

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

Guest

I was advised earlier inorder to print a single label in Access. I would
creat a new command button on a form and add this line to the command button
but I get an error message. Can anyone tell me what is wrong.

Private Sub Command89_Click()
On Error GoTo Err_Command89_Click

stDocName = "LabelsCustomerInvoices"

Me.Refresh

DoCmd.OpenReport "LabelsCustomerInvoices", acViewPreview, , "id = " & Me.id
 
You don't mention what the error message is.

A few things:

Try

Me.Refresh
DoCmd.OpenReport "LabelsCustomerInvoices", acViewPreview, , "id = " & Me.id

The above is all the code you need.

Also, does the above code compile BEFORE you try and run it?

Also, what is the name of the primary key field you used to identify each
record. (normally, the default is "id").

So, try:
Me.Refresh
DoCmd.OpenReport "LabelsCustomerInvoices", acViewPreview, , "id = " & Me!id

Note how I have suggested to try

me!ID

Also, replace "id" with the name of the key id that you have. So, if you use
AccountNumber, then:

"AccountNumber = " & me!AccountNumber

And, note that if accountnumber is a TEXT field, then you must surround this
with quotes like:

"AccountNumber = '" & me!AccountNumber & "'"
 
Back
Top