Print Form

nancy54

Registered User.
Local time
, 20:59
Joined
Jun 19, 2018
Messages
49
How can I print only the record that is visible in a split form. I have a command button to search for the Incident ID, and another button set to Print Object, but it prints all of the records in the database! I don't see any other print options.

Thanks, Nancy
 
You can print the form,
Form.print
Or
Docmd.output acForm....

Or
Make a report,the query of the report uses the key on the form,
Put a button on the form to open the report.

Qry:
Select * from table where [id]=forms!myForm!txtID
 
another answer.
what macro do you use for your Search.
suggest you use ApplyFilter.
this will work with PrintObject macro.
 
Provided by Allen Browne, September 2004. Updated April 2010.

Print the record in the form

The steps
Open your form in design view.
Click the command button in the toolbox (Access 1 - 2003) or on the Controls group of the Design ribbon (Access 2007 and 2010), and click on your form.
If the wizard starts, cancel it. It will not give you the flexibility you need.
Right-click the new command button, and choose Properties. Access opens the Properties box.
On the Other tab, set the Name to something like: cmdPrint
On the Format tab, set the Caption to the text you wish to see on the button, or the Picture if you would prefer a printer or preview icon.
On the Event tab, set the On Click property to: [Event Procedure]
Click the Build button (...) beside this. Access opens the code window.
Paste the code below into the procedure. Replace ID with the name of your primary key field, and MyReport with the name of your report.
The code
Code:
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
 
To arnelgp
Yes, I am using the Apply Filter, Where Condition is:

[Alternate ID] Like "*" & [Forms]![Assign/EMail/Print Report]![Text203] &
"*"

And I am using Print Object for the Print button, but it wants to print the all of the records in the database.
 

Users who are viewing this thread

Back
Top Bottom