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

QueryDefs problem

I'm trying to open a form and use a recordset from a stored procedure
using these instructions:

http://www.mvps.org/access/queries/qry0003.htm

Using MS Access 2002 Project as frontend to sql server.

The user has a form with a dropdown box and an Ok button with the below
code. I get an error regarding the Set qdfParmQry line:
"Object variable or With block variable not set"

Private Sub Ok_Click()

Dim db As Database 'current database
Dim rs As Recordset 'holds query resultset
Dim qdfParmQry As QueryDef 'the actual query object
Set db = CurrentDb()

' sp_NotDropped is the name of the query
Set qdfParmQry = db.QueryDefs("sp_NotDropped")

' DADMISParam is the name of the parameter in the query design
qdfParmQry("DADMISParam") = Me![Combo2]

Set rs = qdfParmQry.OpenRecordset()

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PITWorkSheet"
DoCmd.OpenForm stDocName, acFormDS
Forms![PITWorkSheet].Recordset = rs

Forms![PITWorkSheet].Caption = Me![Combo2].Column(1)

DoCmd.Close acForm, Me.Name, acSaveNo

Exit_Ok_Click:
Exit Sub

Err_Ok_Click:
MsgBox Err.Description
Resume Exit_Ok_Click
End Sub
Many thanks for any help. Today has been frustratin.

Nov 13 '05 #1
2 1637
It seems my db object is somehow not valid. I added
MsgBox db.Name

and get the same error. CurrentDB() doens't seem to be working.

Nov 13 '05 #2
After reallizing the problem is with CurrentDB I did a search on the
forum for that and found that this method does not work in an access
project. I have to use ADO.

Nov 13 '05 #3

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

Similar topics

117
by: Peter Olcott | last post by:
www.halting-problem.com
14
by: MLH | last post by:
I have the following code to list query names in Access 2.0's Immediate Window. Currently, it lists names of all saved queries. Can you suggest a modification that will result in it listing only...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
2
by: Donald Grove | last post by:
I am using Access 2000, but my manual is for Access 2003. In 2003 you can declare databases and querydefs as follows: dim qdf as QueryDef dim dbs as Database but this doesn't seem to work in...
1
by: x taol | last post by:
Set qd = CurrentDb.QueryDefs("qsXX") qd.Parameters("parDt") = "#9/1/2006#" With Me.subFom.Form .RecordSource = qd.SQL .Requery End With in that case, parameter dialog box appear. why? what's...
2
by: Tommy Hayes | last post by:
Hello all, I have the following code snippet in my Access app: Dim dbQueryDef As QueryDef Set dbQueryDef = CurrentDb.QueryDefs("QUERY_NAME") ' (1) Set dbQueryDef = CurrentDb.QueryDefs(26) '...
2
by: Mark | last post by:
Hi All, what I am trying to achieve is rather than having loads of queries stored within the database soley to use as a DAO recordset, I would like to define the query within code. My problem is...
0
by: Michael Scott | last post by:
This is driving me nuts. Can anyone help? I have a program which searches for and analyses Access databases across a corporate network. At one point in the code I am looping quickly through all...
1
NeoPa
by: NeoPa | last post by:
Access QueryDefs Mis-save Subquery SQL Access stores its SQL for Subqueries in a strange manner :s It seems to replace the parentheses "()"with square brackets "" and (often) add an extraneous...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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.