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

No Current Record

bard777
23
I am running some queries on form load to get some summary info on a database.

My query is summing records based on a priority field value (1, 2, or 3) and may find none. When there are no records that meet the criteria for a given priority the line that updates the textbox with the value errs out (below).

here is my code for the textbox:

Expand|Select|Wrap|Line Numbers
  1. Me.txt_low_cnt = Nz((db.OpenRecordset(strSQL)(0)) & " ", "0")
  2.  
I tried an IF db.EOF, but that doesn't work.

Thanks for any ideas.
May 11 '10 #1
3 1301
Megalog
378 Expert 256MB
This NZ statement will never work correctly. You are adding " " to something, which in all cases will never return a null.

This would be a proper example that would return "0" on a null value, but if you need that space in there after a value, you'll have to break this out a bit more to handle both scenarios.

Expand|Select|Wrap|Line Numbers
  1. Me.txt_low_cnt = Nz((db.OpenRecordset(strSQL)(0)), "0") 
May 11 '10 #2
bard777
23
@Megalog
I do not need the space in there, I added that after what you suggested didn't work. I tried again in case I missed something the first time, but it still gives the "No Current Record" error.

It seemed like "no current record" is other than a Null value, so Nz can't handle it. That is why I tried to catch it with EOF, but I had no recordset defined.

Here is what worked:

Expand|Select|Wrap|Line Numbers
  1. Dim rsSum As Recordset
  2.  
  3.  
  4. Set db = CurrentDb
  5.  
  6. strSQL = "<SQL HERE>"
  7. Set rsSum = db.OpenRecordset(strSQL)
  8. If Not rsSum.EOF Then
  9.     Me.txt_high_cnt = rsSum(0)
  10. Else
  11.     Me.txt_high_cnt = "0"
  12. End If
  13.  
May 11 '10 #3
NeoPa
32,556 Expert Mod 16PB
A quicker and easier approach would be to use DCount().
May 12 '10 #4

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

Similar topics

4
by: John | last post by:
Hi Is there a way to print/e-mail the current record as it appears on a form? Thanks Regards
1
by: Tony | last post by:
I have a form in access that has 5 fields for a certain record: 1)Date mailed, 2)Date received, 3)Date completed 4)Foreign Content amount and 5)record number. If the foreign content (FC)is >15% of...
2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
4
by: DBQueen | last post by:
I have a subform which is in Continuous Forms view. I have added a button to the bottom of the page to move to the next record using the button wizard (result: DoCmd.GoToRecord , , acNext). I...
1
by: Richard Coutts | last post by:
I have a Continuous Form where each record has a button that activates another form that simplifies entering values into the record. The activated form has the equivalent of a "Done" button. I'd...
3
by: Maria | last post by:
Is there another way to delete the current record in a subform from the main form, another subform or a sub-subform other than setting focus on a field in the subform and using run command...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: 4004 | last post by:
I would like to open a columnar form (so I can see all the details) from a datasheet form (so I can see what is there) but keep the same recordset and current record. I can do the recordset set...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
2
by: Tom Clavel | last post by:
Scratching my head. I am using the filter property on a combo box .AfterUpdate event to get to a single client record. This is causing a some strange behavior: As I enter a subform, I get a no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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.