Print one record on a report (Newbie here)

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

Guest

Hi there,

I have to say I am very new to all this so please only reply if you are able
to carry me through things step by step. If I have to stick code in someplace
I need to know exactly where to put it.

I am trying to put a button on a form that will take the address information
from the record shown and slap it on a report that is set up like an envelope
so I can print one envelope at a time for customers and not a bunch of labels.

While your at it, can anyone explain why Microsoft Access makes it so
difficult to print one single envelope? I mean not everyone on the planet
wants to send out a mass mailing!

Thanks in advance for any help you are able to offer!!
 
Hi there,

I have to say I am very new to all this so please only reply if you are able
to carry me through things step by step. If I have to stick code in someplace
I need to know exactly where to put it.

I am trying to put a button on a form that will take the address information
from the record shown and slap it on a report that is set up like an envelope
so I can print one envelope at a time for customers and not a bunch of labels.

While your at it, can anyone explain why Microsoft Access makes it so
difficult to print one single envelope? I mean not everyone on the planet
wants to send out a mass mailing!

Thanks in advance for any help you are able to offer!!

It's not difficult at all. Like driving a car, you just need to learn
how!

Your table should have a unique prime key field.
In my example it is named [RecordID].

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records
 
Great!! Thank you!! That did work and my ID was a number.

fredg said:
Hi there,

I have to say I am very new to all this so please only reply if you are able
to carry me through things step by step. If I have to stick code in someplace
I need to know exactly where to put it.

I am trying to put a button on a form that will take the address information
from the record shown and slap it on a report that is set up like an envelope
so I can print one envelope at a time for customers and not a bunch of labels.

While your at it, can anyone explain why Microsoft Access makes it so
difficult to print one single envelope? I mean not everyone on the planet
wants to send out a mass mailing!

Thanks in advance for any help you are able to offer!!

It's not difficult at all. Like driving a car, you just need to learn
how!

Your table should have a unique prime key field.
In my example it is named [RecordID].

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "ReportName", acViewPreview, , "[RecordID] = " &
[RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "ReportName", acViewPreview, ,"[RecordID] = '" &
[RecordID] & "'"

as the Where clause.

For clarity, the single and double quotes are..
"[RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records
 
Back
Top