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!

Code execution has been interrupted

Status
Not open for further replies.

JohnAcc

Technical User
Aug 13, 2003
143
GB
My code crashes when it gets to the msgbox line and i can't for the life of me see why! Any ideas ? If i step through the code it works fine. Thanx in advance for any help

Sub PrintReport()

On Error GoTo ErrHandler
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
MsgBox "The Customer Statement is now printing", vbInformation, "Printing........." ' crashes here
Unload fmLetter
fmMain.Show
Exit Sub

ErrHandler:
MsgBox "Error Printing Report", vbCritical, "Error"
Exit Sub
End Sub

 
Message boxes stop any further code running - no code will run until ok clicked....is that the issue ??

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
No it would crash before the message box came up. I did a search on this from previous discussion threads and I don't think the solution has ever been fully discovered.

Someone suggested the golden art of turning the machine on and off again and this seems to have cured the problem for now.

I don't know what the cause of the problem is and suggestions have ranged from viruses to saving the workbook with a breakpoint in it.

It would be really useful if someone did know the exact cause of this.



 
1. It appears that this is a form under another form, "Main", correct? From what I can see, it is still loaded, but hidden, correct?

What is happening in the code in that form?

2. Geoff has a very good point. Message boxes stop code. What happens if you comment out that message box? Does everything run OK - except of course there is no message?

Gerry
 
It is not to do with the message box - I tried commenting it out and the code still crashed ( 1 line after the message box)

The other form is not hidden. It is unloaded using:

unload fmmain

Like I said I switched the machine off and on again and it has worked fine since.

Very strange..............


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top