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

Access Set DAO Recordset

I've written a function which uses a DAO Recordset. The following statement sets the recordset:
Set rs = db.OpenRecordset("qryLast24Months")

My dilemma is that when my query has a criteria set as follows: [forms]![frmModels].[ModelNum], the function will not work due to a syntax error. However, if I set the criteria to an actual modelnum such as 7300, the function works just fine.

Any help or ideas are appreciated.
May 31 '07 #1
9 2803
Rabbit
12,516 Expert Mod 8TB
I've written a function which uses a DAO Recordset. The following statement sets the recordset:
Set rs = db.OpenRecordset("qryLast24Months")

My dilemma is that when my query has a criteria set as follows: [forms]![frmModels].[ModelNum], the function will not work due to a syntax error. However, if I set the criteria to an actual modelnum such as 7300, the function works just fine.

Any help or ideas are appreciated.
Try changing the . to a !
May 31 '07 #2
ADezii
8,834 Expert 8TB
I've written a function which uses a DAO Recordset. The following statement sets the recordset:
Set rs = db.OpenRecordset("qryLast24Months")

My dilemma is that when my query has a criteria set as follows: [forms]![frmModels].[ModelNum], the function will not work due to a syntax error. However, if I set the criteria to an actual modelnum such as 7300, the function works just fine.

Any help or ideas are appreciated.
This question may seem a little silly, but is frmModels Open?
May 31 '07 #3
This question may seem a little silly, but is frmModels Open?
The form is open...I also tried changing the . to a ! but it still throws a run-time error "Item not found in this collection".
Jun 1 '07 #4
Rabbit
12,516 Expert Mod 8TB
That usually means you've misspelled something.

What's db set to?
Jun 1 '07 #5
That usually means you've misspelled something.

What's db set to?
db is set as follows:
Set db = CurrentDb()
Jun 1 '07 #6
Rabbit
12,516 Expert Mod 8TB
Does the query work outside of code? What's the SQL for the query?
Jun 1 '07 #7
Does the query work outside of code? What's the SQL for the query?
The query does work outside the code so I decided to try to put the query SQL statement in my function instead and was able to get it to work that way. Tks.
Jun 1 '07 #8
Rabbit
12,516 Expert Mod 8TB
The query does work outside the code so I decided to try to put the query SQL statement in my function instead and was able to get it to work that way. Tks.
Well, glad you got it working. Good luck.
Jun 1 '07 #9
JConsulting
603 Expert 512MB
I've written a function which uses a DAO Recordset. The following statement sets the recordset:
Set rs = db.OpenRecordset("qryLast24Months")

My dilemma is that when my query has a criteria set as follows: [forms]![frmModels].[ModelNum], the function will not work due to a syntax error. However, if I set the criteria to an actual modelnum such as 7300, the function works just fine.

Any help or ideas are appreciated.
Jet's pretty strange about recordsets. Sometimes you can get away with using just the query name, others you can't. there is a workaround

Set rs = db.OpenRecordset("select * from qryLast24Months;")

Should do.
J
Jun 3 '07 #10

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

Similar topics

2
by: Josh Strickland | last post by:
I am attempting to create an Access database which uses forms to enter data. The issue I am having is returning the query results from the Stored Procedure back in to the Access Form. ...
5
by: j.mandala | last post by:
Someone is trying to run my Access 2002 database under Access 2003. He has had a number of problems: 1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find it under 2003. Do I...
4
by: JMCN | last post by:
object invalid or no longer set - confusion of the recordset in access 2003. i am currently converting from access 97 to access 2003. majority of the codes converted over perfectly fine, though...
3
by: alex_peri | last post by:
Hello All, I am having problems with sorting a recordset by fields in Access. I have a table with three columns called ID, SNo and Time and would like to sort the records by Time. I would like to...
0
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The...
0
by: jayohare | last post by:
Hello, I have code within my DB application to process credit cards through authorize.net. Ive been using the same code for several years without a problem. I have an order entry computer and...
2
by: ARC | last post by:
Just curious if anyone is having issues with Acc 2007 once the number of objects and complexity increases? I have a fairly large app, with many linked tables, 100's of forms, queries, reports, and...
0
by: Yarik | last post by:
Hello, Here is a sample (and very simple) code that binds an Access 2003 form to a fabricated ADO recordset: ' Create recordset... Dim rs As ADODB.Recordset: Set rs = New ADODB.Recordset '...
6
by: jsacrey | last post by:
Hello everybody, I've got a bit of a situation that I could use some guidance with if possible. I work for an auditing firm where my users audit electronic shipping data for customers to see if...
2
by: curran.george | last post by:
'add one textbox to form1 with Control Source property = ID 'copy/paste the form_load code below: 'Then open the form and then attempt to sort the datasheet 'crashes 2003, error 3450 Access 2007 -...
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...
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...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.