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

Print two (2) pages with one 'Print' button - Access97

Status
Not open for further replies.

lmarles

Technical User
Dec 8, 2000
25
0
0
CA
Access97. I have a form that uses a tab control to create two pages (two tabs).
I have a 'Print' button on each page that, when clicked, will print the data on the page.
The user can tab to either page and then print the page. I would like to set it up so that the user can print the current page or both pages with either of the Print buttons.
I would like to change the print buttons so that when clicked, the user would get a message box with two radio buttons plus an 'OK' button and a 'Cancel' button.
The radio buttons would be:
1. Print current page only
2. Print both pages

Currently, I have both Print buttons set up in 'Properties\Event\On Click\[Event Procedure] as follows:

Private Sub PrintButton_U_Click()
On Error GoTo Err_Print_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.PrintOut acSelection
Exit_Print_Click:
Exit Sub
Err_Print_Click:
MsgBox Err.Description
Resume Exit_Print_Click
End Sub

What must I do to make the desired change? Thanks in advance.

Lou Marles


 
To start, you can't display radio buttons on a message box, so you'll have to create a mini form. Put the option buttons in a frame.

Your mini form will need to pass back two Boolean variables to your main form. One way to do this is to declare Public variables in the Declarations section of your main form's class module, and set them from your mini form's OK and Cancel button click events. The syntax for referring to them in the mini form is "Forms!MyMainForm.variablename". The first variable indicates whether the OK button was clicked, and the second indicates whether both pages are to be printed.

In your Print buttons' Click events, first display the mini form as a modal dialog box. When the mini form is closed, the two variables will be set. Your code should test whether OK was pressed first, and if so, print either the current page or both pages as specified. To print the non-current page, you'll have to bring it to the front in the tab control. To do this, just set the tab control's Value property to the page index of the page control you want to print. When you're done printing, you might want to switch the tab control back to the original page, for your user's convenience. Rick Sprague
 
Hi Rick,

Thanks for your response. I will follow your method.

Lou Marles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top