Recordset parameter query

ctuna02

Registered User.
Local time
Today, 10:44
Joined
Dec 29, 2002
Messages
27
Private Sub Command39_Click()
Dim db As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim rst As Recordset
Set db = CurrentDb()
prm.Value = Me![txtbox0]
Set qdf = db.QueryDefs("qryProbeCardtouchdowncount")
Set rst = db.OpenRecordset("qryProbeCardtouchdowncount")
MsgBox ("Duh " & rst!ID)
End Sub

I'm getting a variable error on the prm.Value Line does anybody have any answers for this?
 
try replacing the set rst= line
Set Rst = QDF.OpenRecordset(dbOpenDynaset)
 
Thanks for your reply but this didn't solve the problem

Private Sub Command39_Click()
Dim db As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim rst As Recordset
Dim Temp As String
Set db = CurrentDb()
Temp = Me.txtbox0
MsgBox ("The Current Probe Card No is" & Temp)
Set qdf = db.QueryDefs("qryProbeCardtouchdowncount")
prm.Value = Temp
Set rst = qdf.OpenRecordset(dbOpenDynaset)
MsgBox ("Duh " & rst!ID)

The Error is coming from the line "prm.Value = Temp" its error 91 something about the variable not being found or valid
 
if the query is a stored query then
put your criteria in the query

Dim db As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim rst As Recordset
Set db = CurrentDb()
For Each PRM In QDF.Parameters
PRM.Value = Eval(PRM.name)
Next PRM
Set rst = qdf.OpenRecordset(dbOpenDynaset)
 
I only have a single parameter , from a single field on an open form that I'm trying to input to the query as the parameter. The Query will return a single record. I would think there would have to be a path to the Query definition using its name in one of the recordset statements or qurery def statements.
 
Last edited:
Dim db As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim rst As Recordset
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryProbeCardtouchdowncount")
the above name is the name of your stored query
although you only have 1 criteria you still have to do
the for each next loop
if you put your criteria in the stored query
i.e =forms![formname]![controlname]
then the query def will work

For Each PRM In QDF.Parameters
PRM.Value = Eval(PRM.name)
Next PRM
Set rst = qdf.OpenRecordset(dbOpenDynaset)
 

Users who are viewing this thread

Back
Top Bottom