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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Printer Help for single pages

Status
Not open for further replies.

Tfrank

Technical User
Jun 19, 2001
30
US
I am trying to create a macro to print the current page of a report. I need a macro because I would like to create a custom toolbar which has an icon that when clicked will print only the current page in the report showing. I am using Access 97 for the database. Does anyone know how the VB code should be written to do this?

I have also created simple code to bring up the Print Dialogue box for the same reason, to print selectable pages by the user. If I click cancel in the Print Dialogue box I get the response “The RunCommand Action was cancelled”. The code is below, is there a way to avoid this response in the cancel button is clicked. I am sure I need to add something to it The code is:

Function Test_Print()
On Error GoTo Err_Test_Print

DoCmd.RunCommand acCmdPrint

Exit_Test_Print:
Exit Function

Err_Test_Print:
MsgBox Err.Description
Resume Exit_Test_Print

End Function

Thanks for the help, I really appreciate it!

Tfrank
 
The error number (Err.Num) for that error is 2501. So for the simple way to avoid that message being show, just add 'If Err.Num <> 2501 then' before 'MsgBox Err.Description'.

If you want to know the error message, just put the Err.Num in the Msgbox:

Err_Test_Print:
If Err.Num <> 2501 then MsgBox Err.Num & vbCrLf & Err.Description
Resume Exit_Test_Print

This is may not the best answer but I'm don't know any other yet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top