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

passing criteria from code

Hello all,

I'm trying to pass data from a control (subform) into a query. When I
run this get a 'Compile error: User defined type not defined' error on
the 'Dim db As Database' line. I'm using 2003. I know I've used
this code before (A97), but now it's not working. Has something
change or do I need to configure something?

I've removed the subform control from this, just to get it working
first.

Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Kits_PB")
qdfParmQry![Kit Name:] = "NikeSmoke"
Set rs = qdfParmQry.OpenRecordset()

thanks for the help.

mike
Apr 29 '07 #1
3 1762
On Apr 29, 4:29 pm, Mike Kruger <j9andm...@earthlink.netwrote:
Hello all,

I'm trying to pass data from a control (subform) into a query. When I
run this get a 'Compile error: User defined type not defined' error on
the 'Dim db As Database' line. I'm using 2003. I know I've used
this code before (A97), but now it's not working. Has something
change or do I need to configure something?

I've removed the subform control from this, just to get it working
first.

Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Kits_PB")
qdfParmQry![Kit Name:] = "NikeSmoke"
Set rs = qdfParmQry.OpenRecordset()

thanks for the help.

mike

Mike -
This is an issue with having the correct references. If you go into
a code window, click on the Tools menu and then References. Make sure
you have all the same references you had in the A97 DB checked off in
your new one.

Apr 29 '07 #2
Thanks, that did it, I thought that it might be a difference between
A97 and A03.

thanks again,
mike
On 29 Apr 2007 14:00:08 -0700, ManningFan <ma********@gmail.com>
wrote:
>On Apr 29, 4:29 pm, Mike Kruger <j9andm...@earthlink.netwrote:
>Hello all,

I'm trying to pass data from a control (subform) into a query. When I
run this get a 'Compile error: User defined type not defined' error on
the 'Dim db As Database' line. I'm using 2003. I know I've used
this code before (A97), but now it's not working. Has something
change or do I need to configure something?

I've removed the subform control from this, just to get it working
first.

Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Kits_PB")
qdfParmQry![Kit Name:] = "NikeSmoke"
Set rs = qdfParmQry.OpenRecordset()

thanks for the help.

mike


Mike -
This is an issue with having the correct references. If you go into
a code window, click on the Tools menu and then References. Make sure
you have all the same references you had in the A97 DB checked off in
your new one.
Apr 30 '07 #3
I'm *pretty sure* that you will need to implicitly qualify those objects
(especially the recordset) as DAO objects.
Dim db As DAO.Database
Dim rs As DAO.Recordset

Here is a "fairly typical" past discussion that may help to clarify:
http://groups.google.ca/group/comp.d...780edf8b532824

Don
"Mike Kruger" <j9*******@earthlink.netwrote in message
news:19********************************@4ax.com...
Hello all,

I'm trying to pass data from a control (subform) into a query. When I
run this get a 'Compile error: User defined type not defined' error on
the 'Dim db As Database' line. I'm using 2003. I know I've used
this code before (A97), but now it's not working. Has something
change or do I need to configure something?

I've removed the subform control from this, just to get it working
first.

Dim db As Database
Dim rs As Recordset
Dim qdfParmQry As QueryDef
Set db = CurrentDb()
Set qdfParmQry = db.QueryDefs("Kits_PB")
qdfParmQry![Kit Name:] = "NikeSmoke"
Set rs = qdfParmQry.OpenRecordset()

thanks for the help.

mike

May 1 '07 #4

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

Similar topics

2
by: Matthew Clement | last post by:
I'm currently building a form (called frmReports) to set the criteria for a query, but I'm having some trouble with syntax and hope that one of the guru's here can help me achieve what I'm do. ...
3
by: MX1 | last post by:
I'm ready to pull the hair out of my head. I have a query with a couple of parameters that I want to get from combo boxes on a form. One parameter is a date with a dynamically calculated year and...
3
by: Peter Bailey | last post by:
Could someone please tell me how to pass criteria as if it were a parameter. I have a routine now that creates the sql string (well almost). at present the parameter is so I can pass one item ie...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
1
by: Roy | last post by:
I'm assuming this is amazingly simple and I'm just missing the boat. On the html side of an asp.net page I have a datagrid, a "search" button, and 8 text boxes for search criteria. A user enters...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
1
by: owengoodhew | last post by:
Guys I need your help/Advice... In my Access Database I have a query (lets say qry1) and in this query i have 2 fields for start and end date, which is provided by 2 Get functions. also i...
14
by: Anja | last post by:
Hi everyone, I have a sub form that references a query to get the results. However, what I want to do is filter the results further based on a certain criteria. How can I tell the sub form to...
5
by: RacerX2000 | last post by:
I have an MS access Database (2000) and Have created a form that sets a variable to a value I would like (Based on other selections in the form) to pass to my query criteria and I get the following...
11
by: Purdue02 | last post by:
I am trying to pass a global variable to criteria in a query using the below code, but the query is returning no results. I have the function ReturnStrCriteria() included in the query's criteria....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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...
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...

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.