I'm assuming it’s a report that's being printed rather than a form. If you
used the wizard to create the button it will include code in the button's
Click event procedure along these lines:
Dim stDocName As String
stDocName = "Elaine"
DoCmd.OpenReport stDocName, acNormal
Add an unbound text box to your form into which the ID can be entered, and
call it TextID say.
Then change the code like so:
Dim stDocName As String, stCriteria As String
stDocName = "YourReportName"
stCriteria = "[ID#] = " & Me.txtID
DoCmd.OpenReport stDocName, _
View:=acNormal, _
WhereCondition:=stCriteria
This assumes that the ID# field is a number data type. Should it be a text
data type warp the value in quotes likes so:
stCriteria = "[ID#] = """ & Me.txtID & """"
You could of course put the button on a form bound to the table or query, in
which case it would print the record(s) with current ID number, rather than
entering the ID number in an unbound form. If you do that you should make
sure the record is saved before printing so that it reflects any changes
made in the form. Add the following line before calling the OpenReport
method:
RunCommand acCmdSaveRecord
Ken Sheridan
Stafford, England