Report Offensive Message

Alternative to print actual form
Thank you for this good article.

I struggled with this due to a complex form that needed a lot of updates, so the following works for me. You need to have a unique ID showing on the form.

-----
Private Sub cmdPrint_Click()
On Error GoTo cmdPrint_Click_Err

DoCmd.GoToControl "ID_mytable"
DoCmd.RunCommand acCmdFilterBySelection
DoCmd.PrintOut acSelection, 1, 1, acHigh, 1, True

cmdPrint_Click_Exit:
Exit Sub

cmdPrint_Click_Err:
MsgBox Error$
Resume cmdPrint_Click_Exit

End Sub
----
Note:
- for "ID_mytable" substitute the name of your control bound to your ID.
- this is for the click event of a button named "cmdPrint"
- using Access 2003 - probably works with earlier versions

Before running the procedure, carry out the actions manually excepting to use the page setup and print dialog so as to set the defaults for printing.

Extras to the code could include turning off the filter before exiting, storing current focus and restoring before exit.

See any 'gotchas' with this?

Mark
Posted by koalajoe
26th Sep 2007