Print most recent record only

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

Guest

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.
 
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
 
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
 
Back
Top