OpenForm action canceled

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

On a form there is a combo box. The combo box's row
source is:

SELECT [queryClassesByTitle].[ClassID],
[queryClassesByTitle].[ClassTitle], [queryClassesByTitle].
[ClassDate], [queryClassesByTitle].[ClassStartTime],
[queryClassesByTitle].[ClassEndTime],
[queryClassesByTitle].[ClassLocation] FROM
queryClassesByTitle;

Before the form is opened, the query asks the user to
enter their Employee ID. I have code that returns a
message box if the user enters an ID that isn't valid...
then cancels the opening of the form (here is part of the
code):

MsgBox "The Employee ID is not valid.",
vbCritical, "Notice:"
Cancel = True

However, after the message box appears and the user clicks
the "ok" button... a standard Access message box appears:

"OpenForm action was canceled."

How can I delete this standard message box from
appearing? It is not necessary to have the two message
boxes appearing.
 
Problem solved... I just deleted the line "MsgBox
Err.Description" from the following switchboard command
button that opens the form:

Err_ClassCalendar_Click:
MsgBox Err.Description
Resume Exit_ClassCalendar_Click

Does this line do anything else besides displaying a
standard message box? So, it is alright if I delete it?

Thanks
 
How are you opening the form, is it from another form? If so, then the error
is probably being generated in the code that opened the form. Place an error
handler in the code and tell it to ignore the error.

Private Sub ......
On Error GoTo ErrorHandler
'some more code here that opens the form
Exit Sub
ErrorHandler:
If Err.Number = 3502 Then Resume Next
'I believe this is the correct #, you'll have to double check it.
MsgBox "An error occurred." & vbCrLf & Err.Description & vbCrLf &
Err.Number
 
The switchboard form would be the "other form" I mention in my other post.
It would be better to add the If statement to the error handler than to get
rid of the error handler, this will leave the error handler in place to
handle other errors that may occur.

--
Wayne Morgan
Microsoft Access MVP


Mark said:
Problem solved... I just deleted the line "MsgBox
Err.Description" from the following switchboard command
button that opens the form:

Err_ClassCalendar_Click:
MsgBox Err.Description
Resume Exit_ClassCalendar_Click

Does this line do anything else besides displaying a
standard message box? So, it is alright if I delete it?

Thanks


-----Original Message-----
On a form there is a combo box. The combo box's row
source is:

SELECT [queryClassesByTitle].[ClassID],
[queryClassesByTitle].[ClassTitle], [queryClassesByTitle].
[ClassDate], [queryClassesByTitle].[ClassStartTime],
[queryClassesByTitle].[ClassEndTime],
[queryClassesByTitle].[ClassLocation] FROM
queryClassesByTitle;

Before the form is opened, the query asks the user to
enter their Employee ID. I have code that returns a
message box if the user enters an ID that isn't valid...
then cancels the opening of the form (here is part of the
code):

MsgBox "The Employee ID is not valid.",
vbCritical, "Notice:"
Cancel = True

However, after the message box appears and the user clicks
the "ok" button... a standard Access message box appears:

"OpenForm action was canceled."

How can I delete this standard message box from
appearing? It is not necessary to have the two message
boxes appearing.


.
 
Back
Top