Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I print out a single record from a Form button

Status
Not open for further replies.

Tfrank

Technical User
Jun 19, 2001
30
0
0
US
I need to add a button to a form that will print only that record displayed, based upon the layout and fields in a report to a single label printer. I know there must be a simple way to do this, but I can't figure it out. I have found a easy way to print out all the records, but I only want to print the one displayed. Thanks for the help.

Tfrank
 
I have never used this for labels, but it works for reports. You might want to give it a try.
Put the following code in the "on click" event of your button. Replace the word Index below with the name of your unique identifier (usually an autonumber)

Private Sub btnOnForm_Click()
DoCmd.RunCommand acCmdRefresh

Dim strDocName As String
Dim strWhere As String
strDocName = "NameOfYourReport"
strWhere = "[Index]=" & Me!Index
DoCmd.OpenReport strDocName, acViewPreview, , strWhere

End Sub

HTH -Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top