Print most recent record only

A

Aaron

I have a Label making database I built. The user can enter in the inforamtion for the label in a form. The user can then do a print preview and a print. That database stores all the label entries. I want to to know if there is a way to limit the print command only to the last record the user entered only

Thank you in advance.
 
F

fredg

I have a Label making database I built. The user can enter in the inforamtion for the label in a form. The user can then do a print preview and a print. That database stores all the label entries. I want to to know if there is a way to limit the print command only to the last record the user entered only?

Thank you in advance.

Aaron,
Only if you have a field which keeps track of the date and time a record
was created
A simpler method woule be to simply open the label report while displaying
the record and coding the form to print just the record displayed.

Add a command button to the form.
Code it's Click event:

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

The above assumes your record has a unique prime key field of Number
datatype.
See Access help files for
Where clause + restrict data to a subset of records
 
G

Greg Kraushaar

another option, assuming you are using incrementing autonumbers as the
key field would be to use a query ad the record source for the report
that only retrieves the recordsource for the highest numbered ID.
Something along the lines of...

SELECT TOP 1 *
FROM tblLabelData
ORDER BY tblLabelData.ID DESC;

I have a Label making database I built. The user can enter in the inforamtion for the label in a form. The user can then do a print preview and a print. That database stores all the label entries. I want to to know if there is a way to limit the print command only to the last record the user entered only?

Thank you in advance.

Aaron,
Only if you have a field which keeps track of the date and time a record
was created
A simpler method woule be to simply open the label report while displaying
the record and coding the form to print just the record displayed.

Add a command button to the form.
Code it's Click event:

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

The above assumes your record has a unique prime key field of Number
datatype.
See Access help files for
Where clause + restrict data to a subset of records
 

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