473,395 Members | 1,613 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,395 software developers and data experts.

DAO OpenRecordset and NULL results?

Using the code hereunder, I query my database (from MS Access VBA code). Some of my queries give empty results, which isn't like by my program.

For example:
Expand|Select|Wrap|Line Numbers
  1. R5SQLC1 = "SELECT COUNT(*) FROM Planning AS D1, Planning AS D2 WHERE D1.werknemer=" & TheWorker & " AND D2.werknemer=" & TheWorker & " AND (D1.AanvangsTijd <= D1.Stoptijd) AND (DateDiff('d', D1, D2) = 1) AND (((D2.AanvangsTijd + 24) - D1.Stoptijd) < 44) AND D1.Datum < D2.Datum"
  2. Debug.Print R5SQLC1
  3. Set C1 = Db.OpenRecordset(R5SQLC1, dbOpenDynaset)
  4.  
This gives as an error:
Run-time error '3601':
Too few parameters, expected 2
For as far as I can tell, this has to do with empty results. As these queries sometimes give empty results, I really need to do something about this. Thing is.. what, and how?

Thanks in advance!
Dec 4 '06 #1
3 3271
Using the code hereunder, I query my database (from MS Access VBA code). Some of my queries give empty results, which isn't like by my program.

For example:
Expand|Select|Wrap|Line Numbers
  1. R5SQLC1 = "SELECT COUNT(*) FROM Planning AS D1, Planning AS D2 WHERE D1.werknemer=" & TheWorker & " AND D2.werknemer=" & TheWorker & " AND (D1.AanvangsTijd <= D1.Stoptijd) AND (DateDiff('d', D1, D2) = 1) AND (((D2.AanvangsTijd + 24) - D1.Stoptijd) < 44) AND D1.Datum < D2.Datum"
  2. Debug.Print R5SQLC1
  3. Set C1 = Db.OpenRecordset(R5SQLC1, dbOpenDynaset)
  4.  
This gives as an error:

For as far as I can tell, this has to do with empty results. As these queries sometimes give empty results, I really need to do something about this. Thing is.. what, and how?

Thanks in advance!
I think, You must the following syntax:

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(Fieldname) FROM Planning AS [D1], Planning AS [D2] WHERE D1.werknemer=" & TheWorker & ", D2.werknemer=" & TheWorker & "... etc
  2.  
Try that.
Dec 5 '06 #2
I think, You must the following syntax:

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(Fieldname) FROM Planning AS [D1], Planning AS [D2] WHERE D1.werknemer=" & TheWorker & ", D2.werknemer=" & TheWorker & "... etc
  2.  
Try that.

Use the following:

count the selected recordset.
n= C1.recordcount
if n>0 then
.... do what you want
else
exit sub
end if

You will not see the error message.

Good Luck.
Dec 5 '06 #3
Thanks all. Doing it the dirty way (testing on the size of the recordset) is what does the trick..

Thanks!
Dec 5 '06 #4

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

Similar topics

5
by: Philippa | last post by:
I'm trying to access data in vba using the openrecordset command. The data in on a SQL Server 2000 database, and I have linked tables to that data. the Table I'm trying to access is one of these...
8
by: Russell Potter | last post by:
I'm trying to create a recordset using "currentDB.OpenRecordSet", using a query as the "source" string (the only parameter: so all the others are set to their defaults which, I believe, means...
0
by: mo. | last post by:
I need some help in accessing Jet database using DAO. I have just started to learn c# and am trying to rewrite a program I have in vb.net to c#. In VB.Net I can do this: Dim ws As...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
0
by: Greg Pyle | last post by:
I have created a parameter query (qryAuthors) that reads three parameters from three different fields on a subform (Subform1). Each time the form record changes, the query updates automatically. ...
18
by: Shawn Yates | last post by:
I have a report that looks up the earliest start time in a query . Right now it opens up the query and grabs the earliest start date like it should. This is the working code: Set rs =...
10
by: syntego | last post by:
I think I have discovered a bug in the handling of null values (vs NULL values) passed as parameters to a stored proc. I have always believed that the database handled NULL and null the same. ...
12
by: dtsmith1984 | last post by:
I have a form that i want to be able to reassign a specific piece of software to a different machine. Form specs: Software Title: cbotitle CDKEY: cbocdkey Old Assignment: cbooldassignment New...
22
by: MLH | last post by:
100 Dim db As Database, rst As Recordset 120 Set db = CurrentDb 140 PString = "SELECT qryBatchList.ReadyFor906, qryBatchList.BatchID FROM qryBatchList WHERE...
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: 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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.