dbTalk Databases Forums  

access 2010 error 2501

comp.databases.ms-access comp.databases.ms-access


Discuss access 2010 error 2501 in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Roger
 
Posts: n/a

Default access 2010 error 2501 - 10-30-2011 , 12:37 PM






I have a cmd button with this code
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
On Error Resume Next

and the form's open event does
cancel = true
exit sub


I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
runtime error 2501
the openform action was cancelled


I get the error event if I add this to the cmd button's form on error
event
On Error Resume Next
If (DataErr = 2501) Then
Response = acDataErrContinue
End If

what am I missing ?

Reply With Quote
  #2  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: access 2010 error 2501 - 10-31-2011 , 09:01 AM






On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?
I think
If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. You
call the open form and if it gets canceled it will return and then
execture the On Error routine.

Reply With Quote
  #3  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 10-31-2011 , 01:10 PM



On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com>
wrote:
Quote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:





I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. *You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -
I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

Reply With Quote
  #4  
Old   
Phil
 
Posts: n/a

Default Re: access 2010 error 2501 - 10-31-2011 , 05:13 PM



On 31/10/2011 19:10:24, Roger wrote:
Quote:
On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com
wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:





I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. *You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
Exit Sub

Err_ReportOptions_Click:
If Err <> 2501 Then ' Report cancelled - No data
MsgBox Err.Description
End If
Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date range",
vbInformation DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil

Reply With Quote
  #5  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-01-2011 , 05:51 AM



On Oct 31, 5:13*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
On 31/10/2011 19:10:24, Roger wrote:





On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com
wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. *You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

*DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
* * Exit Sub

Err_ReportOptions_Click:
* * If Err <> 2501 Then * * * * * * * * * * *' Report cancelled - No data
* * * * MsgBox Err.Description
* * End If
* * Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date range",
vbInformation * * DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -
I created a new accdb
frmTest2 has no controls, and this open event code
Private Sub Form_Open(Cancel As Integer)
Cancel = True
End Sub

frmTest has a command button and the click event code
On Error Resume Next
DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
MsgBox Err.Description


I expect to see a message from the message box with
The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.


with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 retail 7.0.1619 forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done

Reply With Quote
  #6  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-01-2011 , 03:48 PM



On Nov 1, 5:51*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Oct 31, 5:13*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:





On 31/10/2011 19:10:24, Roger wrote:

On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com
wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. *You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

*DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
* * Exit Sub

Err_ReportOptions_Click:
* * If Err <> 2501 Then * * * * * * * * * * *' Report cancelled - No data
* * * * MsgBox Err.Description
* * End If
* * Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date range",
vbInformation * * DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -

I created a new accdb
frmTest2 has no controls, and this open event code
* *Private Sub Form_Open(Cancel As Integer)
* * Cancel = True
* *End Sub

frmTest has a command button and the click event code
* * On Error Resume Next
* * DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
* * MsgBox Err.Description

I expect to see a message from the message box with
* *The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.

with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 * *retail 7.0.1619 * * forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done- Hide quoted text -

- Show quoted text -
I downloaded / applied office 2010 sp 1, and an Oct 2011 hot fix -
neither resolves the problem
I created an onError event in frmTest
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Stop
End Sub

but that doesn't trap the error either
now what ?

Reply With Quote
  #7  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-04-2011 , 06:10 AM



On Nov 1, 3:48*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Nov 1, 5:51*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:





On Oct 31, 5:13*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:

On 31/10/2011 19:10:24, Roger wrote:

On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com
wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement. *You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

*DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me..ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
* * Exit Sub

Err_ReportOptions_Click:
* * If Err <> 2501 Then * * * * * * * * * * *' Report cancelled - No data
* * * * MsgBox Err.Description
* * End If
* * Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date range",
vbInformation * * DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -

I created a new accdb
frmTest2 has no controls, and this open event code
* *Private Sub Form_Open(Cancel As Integer)
* * Cancel = True
* *End Sub

frmTest has a command button and the click event code
* * On Error Resume Next
* * DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
* * MsgBox Err.Description

I expect to see a message from the message box with
* *The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.

with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 * *retail 7.0.1619 * * forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done- Hide quoted text -

- Show quoted text -

I downloaded / applied office 2010 sp 1, and an Oct 2011 hot fix -
neither resolves the problem
I created an onError event in frmTest
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Stop
End Sub

but that doesn't trap the error either
now what ?- Hide quoted text -

- Show quoted text -
on a system with access2007, I created frmTest with a command button
with click-event
Private Sub Command0_Click()
On Error GoTo fErr
DoCmd.OpenForm "frmtest2"
Exit Sub
fErr:
Stop
Exit Sub
End Sub


and I created frmTest2 with open-event
Private Sub Form_Open(Cancel As Integer)
Cancel = True
End Sub

with access2007, clicking the button puts me at the stop statement

I copied the accdb to a system with access2010, clicked the button,
get a microsoft visual basic msgbox

run-time error '2501'
the openform action was canceled

end debug help

click debug, and the docmd. line is highlighted

looks like a vbe bug... but where do I find the fix

Reply With Quote
  #8  
Old   
Phil
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-04-2011 , 10:18 AM



On 04/11/2011 12:10:04, Roger wrote:
Quote:
On Nov 1, 3:48*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:
On Nov 1, 5:51*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:





On Oct 31, 5:13*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:

On 31/10/2011 19:10:24, Roger wrote:

On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com

wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFo
rmEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on
error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement.
*You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where can
cel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

*DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me
.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
* * Exit Sub

Err_ReportOptions_Click:
* * If Err <> 2501 Then * * * * * * * * * *
*' Report cancelled - No data
* * * * MsgBox Err.Description
* * End If
* * Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date ran
ge",
vbInformation * * DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -

I created a new accdb
frmTest2 has no controls, and this open event code
* *Private Sub Form_Open(Cancel As Integer)
* * Cancel = True
* *End Sub

frmTest has a command button and the click event code
* * On Error Resume Next
* * DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
* * MsgBox Err.Description

I expect to see a message from the message box with
* *The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.

with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 * *retail 7.0.1619 * * forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done- H
ide quoted text -

- Show quoted text -

I downloaded / applied office 2010 sp 1, and an Oct 2011 hot fix -
neither resolves the problem
I created an onError event in frmTest
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Stop
End Sub

but that doesn't trap the error either
now what ?- Hide quoted text -

- Show quoted text -

on a system with access2007, I created frmTest with a command button
with click-event
Private Sub Command0_Click()
On Error GoTo fErr
DoCmd.OpenForm "frmtest2"
Exit Sub
fErr:
Stop
Exit Sub
End Sub


and I created frmTest2 with open-event
Private Sub Form_Open(Cancel As Integer)
Cancel = True
End Sub

with access2007, clicking the button puts me at the stop statement

I copied the accdb to a system with access2010, clicked the button,
get a microsoft visual basic msgbox

run-time error '2501'
the openform action was canceled

end debug help

click debug, and the docmd. line is highlighted

looks like a vbe bug... but where do I find the fix

2 Forms

Form 1

Private Sub Form_Open(Cancel As Integer)

DoCmd.CancelEvent

End Sub

Form 2 has a command button on it

Private Sub Command0_Click()

On Error GoTo Command0_Err

DoCmd.OpenForm "Form1"
Exit Sub
Command0_Err:
If Err = 2501 Then
Resume Next
End If

End Sub

No error message
Phil

Reply With Quote
  #9  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-04-2011 , 02:12 PM



On Nov 4, 10:18*am, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:
Quote:
On 04/11/2011 12:10:04, Roger wrote:





On Nov 1, 3:48 pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:
On Nov 1, 5:51 am, Roger <lesperan... (AT) natpro (DOT) com> wrote:

On Oct 31, 5:13 pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:

On 31/10/2011 19:10:24, Roger wrote:

On Oct 31, 9:01 am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com

wrote:
On Oct 30, 1:37 pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFo
rmEdit
fExit:
On Error Resume Next

and the form's open event does
cancel = true
exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
runtime error 2501
the openform action was cancelled

I get the error event if I add this to the cmd button's form on
error
event
On Error Resume Next
If (DataErr = 2501) Then
Response = acDataErrContinue
End If

what am I missing ?

I think
If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement..
You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where can
cel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1,Me
.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
Exit Sub

Err_ReportOptions_Click:
If Err <> 2501 Then
' Report cancelled - No data
MsgBox Err.Description
End If
Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date ran
ge",
vbInformation DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -

I created a new accdb
frmTest2 has no controls, and this open event code
Private Sub Form_Open(Cancel As Integer)
Cancel = True
End Sub

frmTest has a command button and the click event code
On Error Resume Next
DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
MsgBox Err.Description

I expect to see a message from the message box with
The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.

with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 retail 7.0.1619 forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done- H
ide quoted text -

- Show quoted text -

I downloaded / applied office 2010 sp 1, and an Oct 2011 hot fix -
neither resolves the problem
I created an onError event in frmTest
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Stop
End Sub

but that doesn't trap the error either
now what ?- Hide quoted text -

- Show quoted text -

on a system with access2007, I created frmTest with a command button
with click-event
Private Sub Command0_Click()
On Error GoTo fErr
DoCmd.OpenForm "frmtest2"
Exit Sub
fErr:
Stop
Exit Sub
End Sub

and I created frmTest2 with open-event
Private Sub Form_Open(Cancel As Integer)
Cancel = True
End Sub

with access2007, clicking the button puts me at the stop statement

I copied the accdb to a system with access2010, clicked the button,
get a microsoft visual basic msgbox

run-time error '2501'
the openform action was canceled

end debug help

click debug, and the docmd. line is highlighted

looks like a vbe bug... but where do I find the fix

2 Forms

Form 1

Private Sub Form_Open(Cancel As Integer)

* * DoCmd.CancelEvent

End Sub

Form 2 has a command button on it

Private Sub Command0_Click()

* * On Error GoTo Command0_Err

* * DoCmd.OpenForm "Form1"
* * *Exit Sub
Command0_Err:
* * If Err = 2501 Then
* * * * Resume Next
* * End If

End Sub

No error message
Phil- Hide quoted text -

- Show quoted text -
I replaced my 'cancel = true' with your 'DoCmd.CancelEvent'
same problem, I get an access msgbox instead of my 'stop' line

Reply With Quote
  #10  
Old   
Roger
 
Posts: n/a

Default Re: access 2010 error 2501 - 11-04-2011 , 03:24 PM



On Nov 4, 6:10*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Nov 1, 3:48*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:





On Nov 1, 5:51*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:

On Oct 31, 5:13*pm, "Phil" <p... (AT) stantonfamily (DOT) co.uk> wrote:

On 31/10/2011 19:10:24, Roger wrote:

On Oct 31, 9:01*am, Patrick Finucane <patrickfinucan... (AT) gmail (DOT) com
wrote:
On Oct 30, 1:37*pm, Roger <lesperan... (AT) natpro (DOT) com> wrote:

I have a cmd button with this code
* * On Error GoTo fExit
* * DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
fExit:
* * On Error Resume Next

and the form's open event does
* * *cancel = true
* * *exit sub

I'm expecting the error to be trapped at fExit
but I get the standard ms-access popout about
* *runtime error 2501
* *the openform action was cancelled

I get the error event if I add this to the cmd button's form on error
event
* * On Error Resume Next
* * If (DataErr = 2501) Then
* * * * Response = acDataErrContinue
* * End If

what am I missing ?

I think
* If (Err.Number = 2501) then
would work better.

I'm not sure you really need the On Error Resume Next statement.*You
call the open form and if it gets canceled it will return and then
execture the On Error routine.- Hide quoted text -

- Show quoted text -

I agree but this doesn't work
On Error GoTo fExit
DoCmd.OpenForm "frmImportShootSheet", acNormal, , , acFormEdit
exit sub
fExit:
stop

I get the standard ms-access msgbox, click 'debug' and the
docmd.openform line is highlighted
if I step through the function into the form's open event where cancel
is set, the 'exit sub' in the form's open event causes the same
problem

this doesn't happen with access2007, it works correctly

This is the tail end of an OpenReport routine on a Command button

*DoCmd.OpenReport "RptEvents", acViewPreview, , _
"EventSelected Selected = True AND DDiff('d','" & Me.FromDate &
"',Cstr(FromDate)) <=0" _ & " AND DDiff('d','" & DateAdd("d", 1, Me.ToDate) &
"',Cstr(ToDate)) >=0"

Exit_ReportOptions_Click:
* * Exit Sub

Err_ReportOptions_Click:
* * If Err <> 2501 Then * * * * * * * * * **' Report cancelled - No data
* * * * MsgBox Err.Description
* * End If
* * Resume Exit_ReportOptions_Click

End Sub

and this is the bit on the report
Private Sub Report_NoData(Cancel As Integer)

MsgBox gBox "There are no events of the selected type in the date range",
vbInformation * * DoCmd.CancelEvent

End Sub

Does that help? Access 2010

Phil- Hide quoted text -

- Show quoted text -

I created a new accdb
frmTest2 has no controls, and this open event code
* *Private Sub Form_Open(Cancel As Integer)
* * Cancel = True
* *End Sub

frmTest has a command button and the click event code
* * On Error Resume Next
* * DoCmd.OpenForm "frmTest2", acNormal, , , acFormEdit
* * MsgBox Err.Description

I expect to see a message from the message box with
* *The OpenForm action was canceled.

but I get a message box from access with
run time error 2501
The OpenForm action was canceled.

with 'end', 'debug', 'help' buttons, and if I click debug, the
docmd.openform line is highlighted

about vba says version 1619 * *retail 7.0.1619 * * forms3
14.0.6009.100

I'm going to confirm that all windows / office updates has been done-Hide quoted text -

- Show quoted text -

I downloaded / applied office 2010 sp 1, and an Oct 2011 hot fix -
neither resolves the problem
I created an onError event in frmTest
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Stop
End Sub

but that doesn't trap the error either
now what ?- Hide quoted text -

- Show quoted text -

on a system with access2007, I created frmTest with a command button
with click-event
Private Sub Command0_Click()
* * On Error GoTo fErr
* * DoCmd.OpenForm "frmtest2"
* * Exit Sub
fErr:
* * Stop
* * Exit Sub
End Sub

and I created frmTest2 with open-event
Private Sub Form_Open(Cancel As Integer)
* * Cancel = True
End Sub

with access2007, clicking the button puts me at the stop statement

I copied the accdb to a system with access2010, clicked the button,
get a microsoft visual basic msgbox

* *run-time error '2501'
* *the openform action was canceled

* *end debug help

click debug, and the docmd. line is highlighted

looks like a vbe bug... but where do I find the fix- Hide quoted text -

- Show quoted text -
I removed office 2010 sp1, and rebooted my computer - the problem
still exists
I removed three other office 2010 updates, and rebooted, problem fixed
now to identify the exact update(s) that cause the problem

Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.