My problem is that if I cancel the input query, I get the msg: "There was
an error executing the command." In the switchboard code:
HandleButtonClick_Err:
' If the action was cancelled by the user for
' some reason, don't display an error message.
' Instead, resume on the next line.
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox "There was an error executing the command.", vbCritical
Resume HandleButtonClick_Exit
End If
How can I fix this so I don't get that err msg?
One of the difficulties of using the built-in Access switchboard is
that it is user unfriendly and not very functional.
You need to trap the error 2501 in the sub routine's error handler.
If Err = 2501 then
Resume Exit Sub
Else
....... Whatever other error handling you need
Resume somewhere?
End If
I don't know where or how you added the Open Query to the code, so you
may have to add an additional error handler and use that to trap the
error.
On Error GoTo Err_Handler2
DoCmd.OpenQuery "QueryName"
Exit_Sub:
Exit Sub
Err_Handler2:
If Err = 2501 then
Else
MsgBox "Error #: " & Err.Number & " " & Err.Description
End If
Resume Exit_Sub
Or you might be able to simply add the
If Err = 2501 then
line to the existing error handler.
A better solution would be to scrap the switchboard and create your
own, using an unbound form with command buttons. If you use the
Command button wizard to add the buttons, Access will even write most
of the code for you. You will have more control over the switchboard
appearance, are not limited to 8 buttons, and maintenance will be
simpler.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
to the rs! SELECT CASE and changed the #'s in the switchboard table
accordingly. In the switchboard code, conErrDoCmdCancelled was defined:
"Const conErrDoCmdCancelled = 2501"
I just can't figure out why it doesn't "resume next" with the input queries,
but it will with reports, eventhough they too ask for input b/c they are
based on those very same queries! Is there another IF statement I can add
(maybe within the err handling IF stmt) that will avoid this err msg? Or
will that just give me more trouble than it's worth??
I hope I have explained this well enough. If not, just ask and I will try
to clarify. Thanks!
to:
If (Err = conErrDoCmdCancelled) Or Err.Number = 3270 Then
That should fix it.
--
Jeff Conrad - Access Junkie - MVP Alumni
SDET - XAS Services - Microsoft Corporation
Co-author - Microsoft Office Access 2007 Inside Out
Presenter - Microsoft Access 2007 Essentials
http://www.accessmvp.com/JConrad/accessjunkie.html
Access 2007 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
"Gelpaks" wrote in message:
news:C3B09D97-ECD1-4460...@microsoft.com...
I just added this:
Msgbox Err.Number
before..
MsgBox "There was an error executing the command.", vbCritical
The error number then showed up in the Message Box.
--
Jeff Conrad - Access Junkie - MVP Alumni
SDET - XAS Services - Microsoft Corporation
Co-author - Microsoft Office Access 2007 Inside Out
Presenter - Microsoft Access 2007 Essentials
http://www.accessmvp.com/JConrad/accessjunkie.html
Access 2007 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
"Gelpaks" wrote in message:
news:590658F8-E65B-4DDD...@microsoft.com...
--
Jeff Conrad - Access Junkie - MVP Alumni
SDET - XAS Services - Microsoft Corporation
Co-author - Microsoft Office Access 2007 Inside Out
Presenter - Microsoft Access 2007 Essentials
http://www.accessmvp.com/JConrad/accessjunkie.html
Access 2007 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
"Gelpaks" wrote in message:
news:7697B4AE-8181-4502...@microsoft.com...