[AccessD] how to have access ignore a form that is canceled
Heenan, Lambert
Lambert.Heenan at aig.com
Tue Jul 28 08:29:51 CDT 2015
It must be to do with how you are closing the second form. Just tested this code
Private Sub Command0_Click()
On Error GoTo Command0_Click_Error
DoCmd.OpenForm "Form2"
Command0_Click_Exit:
On Error GoTo 0
Exit Sub
Command0_Click_Error:
Select Case Err.Number
Case 0 ' No Error
DoEvents
Case Else
MsgBox "Error " & Err.Number & " : " & Err.Description & " at line " & Erl, vbOKOnly, "Command0_Click"
End Select
End Sub
And in Form2's Open event I have this code
Private Sub Form_Open(Cancel As Integer)
MsgBox Me.Name & " opened"
Cancel = True
End Sub
That will throw error 2501 in the calling code and it is trapped by the error handler.
On the other hand if I run the same code to open the form, but instead of using the Load event to close it, like this...
Private Sub Form_Load()
MsgBox Me.Name & " opened"
DoCmd.Close acForm, Me.Name
End Sub
... then the form closes and no error happens.
Lambert
-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bill Benson
Sent: Monday, July 27, 2015 9:37 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] how to have access ignore a form that is canceled
Apparently not since On Error Resume next did not suppress the notification On Jul 27, 2015 5:37 PM, "Heenan, Lambert" <Lambert.Heenan at aig.com> wrote:
> Can't you just trap error 2501 - "OpenForm action was cancelled" ?
>
> Lambert
>
>
>
> -----Original Message-----
> From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf
> Of Bill Benson
> Sent: Monday, July 27, 2015 5:08 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] how to have access ignore a form that is
> canceled
>
> Yes, that setting is there.
>
> The problem as I see it, is that Access doesn't like me to cancel a
> load of a form when there was a calling routine that opened it. My
> feeling is, so what? Thats the idea. There ought to be a way to trap
> for that and disregard I have forbidden the form to open by design!
>
> On Mon, Jul 27, 2015 at 4:24 PM, Jim Dettman <jimdettman at verizon.net>
> wrote:
>
> > Bill,
> >
> > With the VBA editor window open, click on tools/options. Click
> > the general tab.
> >
> > Make sure your selected to break on unhandled errors.
> >
> > Jim.
> >
> > -----Original Message-----
> > From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On
> > Behalf Of Bill Benson
> > Sent: Monday, July 27, 2015 03:38 PM
> > To: Access Developers discussion and problem solving
> > Subject: [AccessD] how to have access ignore a form that is canceled
> >
> > I am running this
> >
> > DoCmd.OpenForm "frmComments", acNormal, , , acFormEdit, ,
> > CStr(Me.ID)
> >
> > When the openargs is null, I cancel form load.
> >
> > How can I get Access to ignore that the form wont open instead of
> > throwing me into break mode?
> >
> >
> >
> > My error trapping is not working, and the problem arised before
> > Form_Error in the calling form so I cannot continue past it (which
> > makes sense since it is not a data error I guess).
> >
> > Private Sub cmdAddComment_Click()
> > On Error Resume Next
> > DoCmd.OpenForm "frmComments", acNormal, , , acFormEdit, ,
> > CStr(Me.ID) If Err.Number <> 0 Then
> > MsgBox "Could not open the comments form"
> > End If
> > End Sub
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list