PC Review


Reply
 
 
NevilleT
Guest
Posts: n/a
 
      10th Mar 2009
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

 
Reply With Quote
 
 
 
 
Jim Burke in Novi
Guest
Posts: n/a
 
      10th Mar 2009
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.

"NevilleT" wrote:

> 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
>

 
Reply With Quote
 
Tom van Stiphout
Guest
Posts: n/a
 
      10th Mar 2009
On Tue, 10 Mar 2009 01:07:02 -0700, NevilleT
<(E-Mail Removed)> wrote:

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


>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

 
Reply With Quote
 
NevilleT
Guest
Posts: n/a
 
      10th Mar 2009
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.

"Tom van Stiphout" wrote:

> On Tue, 10 Mar 2009 01:07:02 -0700, NevilleT
> <(E-Mail Removed)> wrote:
>
> 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
>
>
> >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

>

 
Reply With Quote
 
Tom van Stiphout
Guest
Posts: n/a
 
      11th Mar 2009
On Tue, 10 Mar 2009 07:05:01 -0700, Jim Burke in Novi
<(E-Mail Removed)> wrote:

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


>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.
>
>"NevilleT" wrote:
>
>> 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
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 2105 Cmenkedi Microsoft Access Form Coding 3 18th Dec 2008 08:41 PM
Error 2105 JohnLute Microsoft Access Form Coding 5 16th Dec 2008 10:41 PM
Why I get Error 2105 Chipcom Microsoft Access 5 5th Aug 2007 09:15 AM
Why I am getting Error 2105 Chipcom Microsoft Access 1 30th Jul 2007 12:24 PM
Error 2105 Rodolfo Fontes Microsoft Access 1 10th Mar 2005 12:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:56 PM.