Create a command button that prints the current record

Create a command button that prints the current record

  1. Open the form in Design view.

  2. Click Control Wizards in the toolbox if it's not already pressed in.

  3. In the toolbox, click Command Button Command Button control.

  4. On the form, click where you want to place the command button.

  5. In the first wizard dialog box, click Record Operations in the Categories box, and then click Print Record in the Actions box.

  6. Follow the directions in the wizard dialog boxes. In the last dialog box, click Finish to display the command button in Design view.

If you want to see the event procedure that makes the button work, open the button's property sheet, and then click the Build button next to the OnClick property box.

Tip   You can print a form's current record in a report by carrying out the OpenReport action in the Click event procedure for a command button. For example, adding the following Visual Basic for Applications code to the Click event procedure for a command button on an Orders form prints the current record in the Invoice report:

Dim strDocName As String
Dim strFilter As String
strDocName = "Invoice"
strFilter = "OrderID = Forms!Orders!OrderID"
DoCmd.OpenReport DocName, acViewNormal, , strFilter