Cancel report

  • Thread starter Thread starter gr
  • Start date Start date
G

gr

Hi all,
How to do this`?
in the details section of my report I have to receive the
contents for 12 registers. I have a Case select to
determine what to do with register 1, 2, etc. in my case
else (if I get more than 12 registers) I want to send an
error message and cancel the report. but the report is not
cancelled. instead I receive the mesbox for every extra
register and the report is opened (which I don't want to
happen) the code for the Case Else:

Case Else
MsgBox "The page you are trying to send is too big for 12
Registers!" & vbCrLf & "Cancelling report .. ", _
vbCritical, "Warning"
Cancel = True
End Select

this code is on the On Format event of details section.
thx all.
 
I'm not exactly clear from your description... While you might have a Case
statement, you didn't include that portion of your expression. You talk
about "register 1, 2, ..." as if these are the names of the fields, but your
use of the Case statement appears to be an attempt to count the number of
"register" fields.

I suspect you are getting the message because of your syntax in the Case
statement.
 
Sorry, not that good in English. What I actually want is
to cancel the report in the Case Else. Which is not
happening. the msgbox of the case else is displayed but
the report is not cancelled, moreover the details on
format event is continue executing. How can I cancel the
report? I did it before just with "Cancel = True" but now
is not working.
thx
 
Is there a reason you don't cancel the report in its On Open event? I don't
think you can cancel a report in another section format event (could be
wrong).
 
I make some calculations on the details section. for
example:
RegisterNo = x +y * z
Case Select RegisterNo

Case 1
.. ..
case 2
....
case n
' Case is not desirable so if it happens Cancel
Report.
 
I'll jump back in for a moment...

Could you simply prevent ever sending the undesirable records to the report
by embedding the calculation in the underlying query, and filtering the
query to exclude those?
 
Back
Top