Help on printing single mailing label???Please

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

Guest

Setup a report to print a mailing label. I want to print just a single
mailing label. This is the code I was given but I seem to be missing
something. The code keeps highlighting on me.id not sure what this means
can anyone elaborate on this.

Me.Refresh

DoCmd.OpenReport "LabelCustomerInvoices", acViewPreview, , "id = " & Me.id

Help please
Lee
 
Setup a report to print a mailing label. I want to print just a single
mailing label. This is the code I was given but I seem to be missing
something. The code keeps highlighting on me.id not sure what this means
can anyone elaborate on this.

Me.Refresh

DoCmd.OpenReport "LabelCustomerInvoices", acViewPreview, , "id = " & Me.id

Help please
Lee

Where is this code placed?
If it is the code behind a command button event on a form it should
work .. IF...
You have a control named [ID] on your form and a field named [ID] in
your report (I would however suggest using the bang with brackets
around the field names, i.e. ["[id] = " & Me![id] ).
Also, as written, [id] is assumed to be a Number datatype.
If [id] is a Text datatype, change the where clause to:
"id = '" & Me.id & "'"

If you have this code in a Module, it won't work, as the Me keyword
would be unrecognized.
 
something. The code keeps highlighting on me.id not sure what this
means
can anyone elaborate on this.

Me.Refresh

DoCmd.OpenReport "LabelCustomerInvoices", acViewPreview, , "id = " & Me.id


Try using me!ID in place of me.ID

The above assumes you have a key id field called ID. If yours is different
then the above..then you need to modify your code to use whatever name
(field) you used for the key id.

So, I guess the next question is what is the name of the key field, or a
field that can uniquely identify the record we are looking at?

Most of the time we use a field called "ID", but I can't read your mind!!

so,...what is the name of a field that you can idenfiy the current reocrd?
 
Albert your suggestion did work. This is my code now.
DoCmd.OpenReport "LabelsInsuranceCoQuery", acViewPreview, , "id = " & Me![B#]
Although when I click on the print label button a screen comes up asking for
the id. I type in the B# that I need and click ok and it goes right to a
full page of labels in my database. Not sure how to choose just one label..
Lee
 
If the name of the unzite key field in your database is B#

The, your code can be:

DoCmd.OpenReport "LabelsInsuranceCoQuery", acViewPreview, , "[B#] = " &
Me![B#]

(and, as a rule..you should adved strange symbols (and spaces) in your field
names).

Also, the above assumes that b# us a number type field..and not a text type
(if it is..then you need to change the above).
 
Thankyou Albert for all your help!! Works like a charm. I read up and as
you mentioned no strange names or signs in the fields. I have changed all of
the data base to reflect no spaces or weird signs. Once again thank you. I
guess it would be a good pratice to save all the codes...I will be looking
for you in the future if I need help. Once again thank you!!! Im so
excited.....

Lee
 

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

Back
Top