2105 Error

N

NevilleT

I am trying to supress a 2105 error message that occurs if I cancel an open
form event.

I have a form (form 1) that opens another form (form 2). If certain
conditions are not met in the second form open event, the open is cancelled.
A third form (Form 3) is opened instead.

Form 1

strDocName = "frmMSP"
DoCmd.OpenForm (strDocName)

Form 2 (frmMSP)

' run a query to check some data including a field called UseMSP

If rst!UseMSP = False Then
subOpenForms ("frmGanttChart")
Cancel = True
GoTo Exit_Form_Open
End If

Exit_Form_Open:
On Error GoTo 0
Exit Sub
 
J

Jim Burke in Novi

You should check for that condition in the form 1 code before opening form 2,
rather than check it in form 2's open event. if the condition is true open
form 3, else open form 2. Seems like that should be easy enough to do. The
other alternative is to use an 'on error resume next' statement to ignore the
error that gets generated on the cancel, but I see no reason for doing that
as opposed to my other suggestion.
 
T

Tom van Stiphout

On Tue, 10 Mar 2009 01:07:02 -0700, NevilleT

In the error handler you can write:
if err.Number=2205 then
'do nothing
else
Msgbox Err.Description 'etc. your normal error handler
end if

-Tom.
Microsoft Access MVP
 
N

NevilleT

I once worked with a guy who had the concept of a phantom programmer. If he
struck a problem he would explain it to his phantom friend. Nine times out
of ten in explaining it, he would come up with the solution. When I first
did the post, I thought the same thing about selecting the form in Form 1.
Thought I would post it anyway and see if I could learn anything. If someone
else had a creative solution. Think I will take the advice of Jim and change
the first form.

Thanks Jim and Tom.
 
T

Tom van Stiphout

On Tue, 10 Mar 2009 07:05:01 -0700, Jim Burke in Novi

I disagree. If you do as you say, you may have to repeat that code in
several other forms. Much better to write it once in the Form_Open
event. Then even if another innocent developer adds another form,
forgetting to add the magic code, the system will continue to work.

-Tom.
Microsoft Access MVP
 

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