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

Menu with list of reports to Print

Status
Not open for further replies.

Geeklette

Technical User
Jun 3, 2003
3
US
Hi. I'm taking a VBA class in 2 weeks, so bear with me please! I have a form with 10 reports listed on it with a checkbox by each. Checkboxes are named check1, check2, etc. There is also a listbox with rep names. I need user to be able to check one or more reports and then press a PRINT button. If they forget to choose a rep, I want a message to display. Here is the event code on the PRINT button. I've tried various things. It always bombs if I have an unchecked checkbox before a checked box. Please VBA gurus ... this will be easy for you but it's pretty greek to me right now. What should my code look like to accomplish the above with no errors.
Private Sub cmbPrintReports_Click()
If IsNull(RepName) Then
MsgBox "Please choose name of Sales Rep"
End If
If [check1] Then
DoCmd OpenReport "Report1", acviewNormal
End If
If [check2] Then
DoCmd OpenReport "Report2", acviewNormal
End If
.....and so on for 8 more reports, then
Exit Sub
 
It seems to me that after issuing the MsgBox, you would want to Exit Sub rather than continue down into the code that tests the check boxes.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top