473,386 Members | 2,129 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,386 software developers and data experts.

Report Shows #Error When Recordset Empty

well i got it to work, with the Is Not Null fuction, I put it in the Weekstart string and it worked. So thank you very much for all the help. Saddly i have another small problem that doesn't make sence.


The new problem I have is that this was my last big thing, so I updated all of the data in my table and so all the reports do not have any records in them yet. So all of my total counts are 0 in my reports but instead of 0 they are Errors for some wierd reason, and i am not sure why at all, but my macros and some delete querys stoped working becouse it is returning an Error insted of 0. I have got caught way off gaurd with that.
May 25 '07 #1
17 4002
NeoPa
32,556 Expert Mod 16PB
The thread that this was split from is Invalid Use Of Null In Query.
May 25 '07 #2
NeoPa
32,556 Expert Mod 16PB
This happens when the bound recordset is empty.
You can handle this by checking the status in the OnOpen event procedure.
Me.Recordset.EOF is what you need to check.
May 25 '07 #3
I do not have anything in the on open even procedure, i found a formula that sets null to zero but it doesn't work.


Expand|Select|Wrap|Line Numbers
  1. Public Function NullToZero( TheValue as Variant)
  2.  
  3. 'This function converts Null to Zero
  4.  
  5. 'It also converts Non Existing Data to Zero
  6.  
  7. On Error Goto NullToZero_Err
  8.  
  9.  
  10.  
  11. If ISNull(TheValue) then
  12.  
  13. NullToZero = 0
  14.  
  15. Else
  16.  
  17. NullToZero = TheValue
  18.  
  19. End if
  20.  
  21. Exit Function
  22.  
  23.  
  24.  
  25. NullToZero_Err:
  26.  
  27. 'This function would only generate an error
  28.  
  29. 'if the data in TheValue doesn't exist at all.
  30.  
  31. NullToZero = 0
  32.  
  33. Exit Function
  34.  
  35. End Function
May 26 '07 #4
NeoPa
32,556 Expert Mod 16PB
Are you talking about my post earlier or the other thread related to the IsNull question?
This thread is about the problem when a report is empty.
May 26 '07 #5
I got the ISNull function to finally start working. but then i came up with another problem, i shouldn't have posted it there, i just didn't have the time to start a new thread.
May 26 '07 #6
NeoPa
32,556 Expert Mod 16PB
Don't worry about that. It's sorted.
Are you happy that you have an answer to this question now though?
May 26 '07 #7
Yes, i couldn't put my database on the server untill that was fixed lol. Thank you very much, it helped alot. Now i just need to find out how to fix this #Error problem. Access should know and be able to auto correct this but it doesn't.

Thank you again for helping.
May 27 '07 #8
NeoPa
32,556 Expert Mod 16PB
Yes, i couldn't put my database on the server untill that was fixed lol. Thank you very much, it helped alot. Now i just need to find out how to fix this #Error problem. Access should know and be able to auto correct this but it doesn't.

Thank you again for helping.
I'm pleased the other problem is good, but I'm asking about the #Error problem (see title of thread). From your comment I assume that this is still outstanding.

Go back to my post #3, and tell me what, if anything, you have difficulty with. We can then lead you to a solution where the report will return an error message (MsgBox()) rather than opening, when there is no data to display. This will get rid of the #Error problem.
May 27 '07 #9
My mistake,

I put Me.Recordset.EOF in the on open procedure, but i have a feeling that is not what you ment. The problem with the msg box poping up when i open a report is that i have these reports opening up when my username signs on, this way it can run the querys, and the macros that i have, this way it all auto updates at the same time. I have a feeling that if a msg box pops up for a report that it will still send back an error in my startup code
May 27 '07 #10
NeoPa
32,556 Expert Mod 16PB
I don't know what automatic processes you have which kick off this report, but in general, if it's kicked off automatically, you will probably not want the MsgBox() call. In that case, I'd simply close the report from inside when the code detects that it has no data with which to run.
I don't remember the precise details of how to detect this within the code, but I would have thought Me.Recordset.EOF within the OnOpen event procedure would be along the right lines.
May 27 '07 #11
NeoPa
32,556 Expert Mod 16PB
I thought I might just save you some time digging up the right syntax.
What I found was that you could have some code a bit like the following to do what you need :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2.     Cancel = (Me.Recordset.RecordCount = 0)
  3. End Sub
May 27 '07 #12
Thank you for hunting down the code. I put it in and it gave me error that code could not be run in MDE. I tried to put an if statement just to close if recordset = 0 but it didn't seem to work. I am not sure if that would work since it comes out in an #error not a 0, but maybe Null would work if possible.
May 28 '07 #13
NeoPa
32,556 Expert Mod 16PB
Thank you for hunting down the code. I put it in and it gave me error that code could not be run in MDE. I tried to put an if statement just to close if recordset = 0 but it didn't seem to work. I am not sure if that would work since it comes out in an #error not a 0, but maybe Null would work if possible.
I don't use MDEs myself, but I looked up 'Recordset.RecordCount' under both the DAO library and the ADODB one, and they were both there as specified. I found nothing in comments to indicate that they could not be used in MDEs.
I'm sorry, I'm not sure why you've got that error :(
May 29 '07 #14
NeoPa
32,556 Expert Mod 16PB
Yes I am :(
The Report object doesn't contain a Recordset object. I'm sorry.
I'm sure there must be another way of doing this, but I can't think of it just now.
May 29 '07 #15
Thats not a problem, thank you for helping me. i think that formula would work that i posted above, at least it is supposed to, i had found it on a access web site. i just can not recall it off the top of my head.
May 29 '07 #16
NeoPa
32,556 Expert Mod 16PB
I too am frustrated :(
I'm sure I've dealt with this before, if only theoretically for a member here. If anything comes to me I'll try to remember this thread and post it.
May 29 '07 #17
Thank you very much for all of your help
May 30 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: Den | last post by:
I have a report where at the report footer, I have a field that sums up the total of a field in the report. My problem is, when the report is empty the field shows #error. Would someone tell me a...
3
by: deejayquai | last post by:
Hi I've created a crosstab query and displayed it as a sub-report in my main report. This is fine until the data changes and the column names become incorrect. I know I have to create a...
3
by: melnhed | last post by:
---Report the current filtered records from a Form--- Hello All, I've seen this topic discussed before, but the solution described then doesn't work in my particular case. My Config: ...
2
by: Keith Wilby | last post by:
I have a report that is based upon a crosstab query which return only the columns (fields) it has data for. When my report runs it sometimes fails because some of the text boxes don't have a field...
1
by: Intrepid_Yellow | last post by:
Hi, I have the following code that runs my report generator. The user selects a table from a combo box, then whatever fields they want from a list box. (This part all works and the report runs...
13
by: alive84 | last post by:
Hi there, I have a two problems concerning option button values on a report and data report creator reports. The situation: I have three option value boxes two have 3 option and one has...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
4
kcdoell
by: kcdoell | last post by:
Hello: What is the best way to stop a report from running if the query is empty? Currently, I have a form that has a command button on it. The user has to make selections from 3 combo boxes on...
14
ollyb303
by: ollyb303 | last post by:
Hi, I am trying to create a dynamic crosstab report which will display number of calls handled (I work for a call centre) per day grouped by supervisor. I have one crosstab query (Query1) which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.