473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Error 2501 No-brainer

In an old A97 app I trap for error 2501 in a report's calling code just in
case there are no records to return (set cancel = True in the report's No
Data event). This doesn't seem to work in my A2k3 version of the same app.
I know I'm missing something simple here but my brain's gone home already.
Anyone help?

Thanks - Keith.
Feb 2 '06 #1
7 2942
It should work fine in A2003, Keith, so there must be another factor.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" <he**@there.com> wrote in message
news:43********@glkas0286.greenlnk.net...
In an old A97 app I trap for error 2501 in a report's calling code just in
case there are no records to return (set cancel = True in the report's No
Data event). This doesn't seem to work in my A2k3 version of the same
app. I know I'm missing something simple here but my brain's gone home
already. Anyone help?

Thanks - Keith.

Feb 2 '06 #2
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
It should work fine in A2003, Keith, so there must be another factor.


Hi Allen,

I've got this in the No Data event of the report:

MsgBox "No items matching criteria.", vbInformation, gcApplication
Cancel = True

and this in the Click event of a command button on a form (simplified):

On Error GoTo errTrap

DoCmd.OpenReport Forms(gcFrmPrint).lstReport.Column(1), acViewPreview, ,
strFilter

' Hide dialog
Me.Visible = False

Exit Sub

errTrap:
If Err.Number <> 2501 Then
Call libErrorHandler(Me.Name, cProcedure)
End If

The other code just sets up filter criteria for strFilter. I could have
sworn this worked in A97, any more thoughts?

Keith.
Feb 2 '06 #3
That looks pretty standard, Keith.

I always use a Resume in the errTrap section instead of just letting it fall
out of the proc.

How about setting a breakpoint (F9), and single-stepping through the code to
see:
a) if another error is occurring, or
b) if err 2501 is occuring somewhere else (such as in libErrHander.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Wilby" <he**@there.com> wrote in message
news:43**********@glkas0286.greenlnk.net...
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
It should work fine in A2003, Keith, so there must be another factor.


Hi Allen,

I've got this in the No Data event of the report:

MsgBox "No items matching criteria.", vbInformation, gcApplication
Cancel = True

and this in the Click event of a command button on a form (simplified):

On Error GoTo errTrap

DoCmd.OpenReport Forms(gcFrmPrint).lstReport.Column(1), acViewPreview, ,
strFilter

' Hide dialog
Me.Visible = False

Exit Sub

errTrap:
If Err.Number <> 2501 Then
Call libErrorHandler(Me.Name, cProcedure)
End If

The other code just sets up filter criteria for strFilter. I could have
sworn this worked in A97, any more thoughts?

Keith.

Feb 3 '06 #4
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
That looks pretty standard, Keith.

I always use a Resume in the errTrap section instead of just letting it
fall out of the proc.

How about setting a breakpoint (F9), and single-stepping through the code
to see:
a) if another error is occurring, or
b) if err 2501 is occuring somewhere else (such as in libErrHander.)


Thanks Allen, I still can't understand why it's suddenly stopped working, I
haven't changed anything. This is going to turn out to be something really
daft!

Keith.
Feb 3 '06 #5
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
That looks pretty standard, Keith.

I always use a Resume in the errTrap section instead of just letting it
fall out of the proc.

How about setting a breakpoint (F9), and single-stepping through the code
to see:
a) if another error is occurring, or
b) if err 2501 is occuring somewhere else (such as in libErrHander.)


I've just created a very simple mdb file with one table, one form and one
report. On the form is a command button with

On Error GoTo Err_Trap
DoCmd.OpenReport "Report1", acViewPreview, , "[Text1] = 'qwerty'"

Err_Trap:
If err.Number = 2501 Then MsgBox "barf!"

in the click event and "cancel = true" in the report's No Data event, and
*still* the error isn't trapped. Could it be my installation of Access
playing up (clutching at straws now)?

Keith.
Feb 3 '06 #6
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43***********************@per-qv1-newsreader-01.iinet.net.au...
That looks pretty standard, Keith.

I always use a Resume in the errTrap section instead of just letting it
fall out of the proc.

How about setting a breakpoint (F9), and single-stepping through the code
to see:
a) if another error is occurring, or
b) if err 2501 is occuring somewhere else (such as in libErrHander.)


Well I said it was going to be something daft and it is! In the code
options the "break on all errors" option was selected. I changed it to
"break on unhandled errors" and the error is now trapped. I'm not entirely
sure I understand the difference between the options, can you point me at
any documentation? Thanks for your patience.

Keith.
Feb 3 '06 #7
"Keith Wilby" <he**@there.com> wrote in
news:43********@glkas0286.greenlnk.net:
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43e2a64d$0$31213$5a62ac22@per-qv1-newsreader- 01.iinet.net. au...
That looks pretty standard, Keith.

I always use a Resume in the errTrap section instead of just
letting it fall out of the proc.

How about setting a breakpoint (F9), and single-stepping
through the code to see:
a) if another error is occurring, or
b) if err 2501 is occuring somewhere else (such as in
libErrHander.)


Well I said it was going to be something daft and it is! In
the code options the "break on all errors" option was
selected. I changed it to "break on unhandled errors" and the
error is now trapped. I'm not entirely sure I understand the
difference between the options, can you point me at any
documentation? Thanks for your patience.

Keith.

I don't know of good documantation. However

the "Break on all Errors" option is there to help debug an
application which has error handlers built in, "Break on all
errors" disables all error handling, so you wind up in debug
mode when a error does crop up, without having to comment out or
modify code.

Personally, I'd like it to be non-persistent, because I
sometimes forget to reset it to the correct

--
Bob Quintal

PA is y I've altered my email address.
Feb 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ColinWard | last post by:
My previous message was blank so Im trying again. I have a button on a form which opens the Import dialogue box. This works fine except if I click on the "X" to close the form I get Run-Time Error...
5
by: Bob | last post by:
Hi Everybody I hope you can help. 2 related questions. 1. I am looking for a way to replace the confusing message box that comes up when a user trys to open a form without putting data in...
1
by: Bob Dydd | last post by:
Hi everyone It's me again. I have an access 2000 database with 12 landscape reports which sometimes have to be FAXED and other times printed, so I have written the following code and put it...
5
by: fearblanco | last post by:
Hello - I am receiving the below error message when attempting to open a report. This database is used by approximately 20 users and only one user is having this problem (even I can't duplicate...
3
by: Ed Robichaud | last post by:
I'm temporarily stumped on how to handle/suppress an error (2501) if a user cancels sending an email. I'm using DoCmd.SendObject to trigger an Outlook send window, which works OK, but if the msg...
4
by: Keith | last post by:
I have the following code in the On No Data event of a report: **** On Error GoTo err_trap MsgBox "No items matching criteria.", vbInformation, gcApplication Cancel = True err_trap: If...
33
by: Anthony England | last post by:
I am considering general error handling routines and have written a sample function to look up an ID in a table. The function returns True if it can find the ID and create a recordset based on...
0
by: AccessAl | last post by:
Sorry for asking but I could not find any response and can only loop thru 25 pages every so often. I know this has been asked multiple times, but I cannot seem to find an answer that I haven 't...
8
by: sara | last post by:
I have a report that runs fine with data. If there is no data, I have its NO Data event sending a MsgBox and cancelling the report. Then it seems I still get the 2501 message on the Open Report...
7
sassy2009
by: sassy2009 | last post by:
Hello, I am running an insert query from xl spreadsheet using the DoCmd.RunSQL to insert values from the spreadsheet into the Access database. When i run this query it gives an error saying "...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.