VBA code does not break when printing

V

Vadim Rapp

Hello,

I create a report and put the following VBA code:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
MsgBox "hello"
End Sub

In VBA, I put debugging break on Msgbpx line. Then I open the report for
preview, and the code breaks as it should. But then when I print from the
preview, the code runs and I see another "hello", but it does not break.

If I print the report without preview, it also does not break, though it
shows the message, so the code does run.

Why it does not break?

thanks
 
V

Vadim Rapp

AD> same here, but no idea why this happens
AD> perhaps report print has a special mode, not breakable

I see what's even more interesting is that errors are quietly ignored. Try
this:

==================
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo Er
MsgBox "starting"
CurrentProject.Connection.Execute ("bogus") ' should result in error
MsgBox "OK"
Exit Sub
Er:
MsgBox "error"
End Sub
==================

It shows "starting", but then neither "OK", nor "error"...
 
A

aaron.kempf

yeah I've noticed this before

I would just make sure you don't raise an error in this section
because it will be sunk

I mean.. make it so that no matter what it does it won't error


we had to use this detail_print event for some 'checkprinting'
application many many years ago

it's really not that big of a deal; just a quirk.. right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top