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

report preview not closing before print command

Status
Not open for further replies.

xentaur

Programmer
Nov 17, 2003
35
AU
greetings VeeBees

What I want to do: interface presents lists of reports for user. user clicks buttons to view reports in preview. User closes report and is prompted with vbyesno if they wish to print the report. After choosing yes/no, user is returned to report menu.

Problem:

Using Access 2000 and trying to get this damn thing to work.
In the report I have an 'onclose' event to open the report menu ie:

DoCmd.OpenForm "ReportMenu", acNormal

OnOpen code for ReportMenu as follows:

DoCmd.Echo True
If printon = "" Then GoTo finish
response = MsgBox("do you wish to print the " & printon & " report?", vbYesNo)
If response = vbYes Then DoCmd.OpenReport printon, AcViewNormal
finish:
printon = ""
DoCmd.Restore

printon is a public string variable which is set to the name of the report being viewed. I've checked that this is working by putting a msgbox up.

The error being returned is:
"Run-time error 2585. This action
cant be carried out while processing a form or report event"
and highlights the print line.

the msgbox is coming up over the report preview ie before it has closed. I've tried a 'docmd.close acreport' prior to printing it but get the same error. I've tried doevents in a loop checking the openstate value before printing. I've tried pulling each and every hair from my head but still no luck.

Hello (hello, hello)...Is there anybody out there...?

Any insight from the gurus would be most welcome.

Cheers

xentaur.
 
Why not just close the menu after opening the report in the same area?

E.G.

docmd.openreport ...
docmd.Close acForm, "frmMenu"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top