print one record only shortcut

G

Guest

Hi all; I made an extremely basic database, one table, one form. When I
enter a new record in my form, how can I print only that record without
specifying that in the print menu? I can already see someone printing out
all 5,000 of our records the first day.


Thanks,

Andy
 
F

fredg

Hi all; I made an extremely basic database, one table, one form. When I
enter a new record in my form, how can I print only that record without
specifying that in the print menu? I can already see someone printing out
all 5,000 of our records the first day.

Thanks,

Andy

Your table should have a unique prime key field.
In my example it is named [RecordID].
Change [RecordID] to whatever the actual name of your unique prime key
field is.

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'
 
G

Guest

Thanks Fred! I'd hate to waste paper.

fredg said:
Hi all; I made an extremely basic database, one table, one form. When I
enter a new record in my form, how can I print only that record without
specifying that in the print menu? I can already see someone printing out
all 5,000 of our records the first day.

Thanks,

Andy

Your table should have a unique prime key field.
In my example it is named [RecordID].
Change [RecordID] to whatever the actual name of your unique prime key
field is.

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'
 
P

papajohn

Hi all; I made an extremely basic database, one table, one form. When I
enter a new record in my form, how can I print only that record without
specifying that in the print menu? I can already see someone printing out
all 5,000 of our records the first day.

Thanks,

Andy

Your table should have a unique prime key field.
In my example it is named [RecordID].
Change [RecordID] to whatever the actual name of your unique prime key
field is.

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'


If your form had a subform, and you wanted to print only the record on
the main form and only one of the records on the subform ... how would
you construct the Where clause to print just the one record with just
the one subform record? I have a database that prints a single
record, but it also prints every record in the subform (do not want)

If I'm not including enough info to get a good answer, please give
this newbie a point in the right direction :)

Thanks!
 

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

Top