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