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!

Print Report When Form Closes

Status
Not open for further replies.

labprof

Technical User
Jan 26, 2006
49
US
Can someone tell me how I could print a report when a form closes?

I have a form in my database. It is based on a table for collecting lab data. I then have a report, based on a query of that data.

I would like to somehow have a message box come up when the tech closes the form (by the way, I have a button on the form to close) that asks "Do You Want To Print A Report?" And then give the tech the option of YES or NO.
If yes I would like the report to print and then close the form. If NO I would just like the form to close.

I'm just starting to understand a little bit about basic code writing. So I don't know what to write to accomplish this.

Can someone lend a hand?

It would be sincerely appreciated.

Labprof
 

Try this on the On Close event of the form:
Code:
MsgBox "Do You Want to Print a Report?", acYesNO

   If MsgBox = -1 Then
      DoCmd.acReport "myReportName"
   End If

You'll want to make use of the little help menus that pop up when you press . or use keywords, because I'm not good with syntax on the fly - but that should get you going.

Double check the MsgBox value in the help of VBA - I think a yes is -1, but I could be wrong.




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top