VBA code to close an Access user notification message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've used an OnNoData event to cancel print preview if the bound query is an
empty recordset. The report is the second of two that open with a button
click on my parameter entry form, so I'd just like to add a line to close the
Access message box that tells me the 2nd report was cancelled. The end users
just don't need to be bothered with that. I'm not sure what kind of object
the notification is. I tried just using a DoCmd.SetWarnings (WarningsOff),
but that wasn't it. Can someone help me out with a couple lines of code to
do this? Thanks!
 
slarbie said:
I've used an OnNoData event to cancel print preview if the bound query is an
empty recordset. The report is the second of two that open with a button
click on my parameter entry form, so I'd just like to add a line to close the
Access message box that tells me the 2nd report was cancelled. The end users
just don't need to be bothered with that. I'm not sure what kind of object
the notification is. I tried just using a DoCmd.SetWarnings (WarningsOff),
but that wasn't it. Can someone help me out with a couple lines of code to
do this?


Way easier to prevent the message tha to close it after it
appears. This is pretty straightforward using standard
error handling code in the button's Click event. The
general idea is:

Sub yourbutton_Click()
Dim . . .
On Error GoTo Errhandler
. . .
DoCmd.OpenReport . . .
AllDone:
Exit Sub

Errhandler:
Select Case Err.Number
Case 2501
Resume AllDone
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume AllDone
End Select
End Sub

If you used the wizard to generate the event procedure, you
probaly already have skeletal error handling and just need
to change it around to make it like the above.
 
I guess I'm not understanding how that's going to help if the message I want
to close doesn't appear to be an error message... ??
 
Maybe you should explain what message you are getting. I
assumed it was the standard "action was canceled" message.

If it was something else, then you must have code either in
the report's NoData event or in the form button's error
handler to display the message. In this case, you can do
what ever you want with it, either remove the code for the
message or use your own pop up form with a timer event to
close itself after some suitable delay.

I know that's pretty vague, but it's the best I can do
without more details of what you are doing in your code.
 
Thanks and sorry for being a little dense. Guess I could have tried your
suggestion before questioning it. Your assumption was correct about what
message it was, and when I adapted your code into my form, it did quite
successfully prevent display of the message. Thanks so much for your help
AND your patience. !! :)

Marshall Barton said:
Maybe you should explain what message you are getting. I
assumed it was the standard "action was canceled" message.

If it was something else, then you must have code either in
the report's NoData event or in the form button's error
handler to display the message. In this case, you can do
what ever you want with it, either remove the code for the
message or use your own pop up form with a timer event to
close itself after some suitable delay.

I know that's pretty vague, but it's the best I can do
without more details of what you are doing in your code.
--
Marsh
MVP [MS Access]

I guess I'm not understanding how that's going to help if the message I want
to close doesn't appear to be an error message... ??
 

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

Back
Top