Print selected record multiple times
On Thu, 29 May 2008 09:19:04 -0700, Blondyeee wrote:
I need to create a command button on a form that will allow me to print the
single record I am viewing 3 times on one page (need to be cut apart for 3
different uses). I am a very inexperienced user. I was able to create a
command button to print a single record, however, I need it to appear on the
page 3 times.
Thanks!
In the report's Detail Section ... Create a report and simply add the
same controls (with identical control sources) to the report 3 times,
laid out in 3 different row positions in the report. Like this:
In the report's Detail Section ... Create a report and simply add the
same controls (with identical control sources) to the report 3 times,
laid out in 3 different row positions in the report. Like this:
In the report's Detail Section ... Create a report and simply add the
same controls (with identical control sources) to the report 3 times,
laid out in 3 different row positions in the report. Like this:
The above will print the same values 3 times in the detail section for
each record.
Then, to print just the one record you are viewing in the form....
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
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
|