Type mismatch in Query

sad92027

New member
Local time
Today, 03:11
Joined
Sep 29, 2010
Messages
8
I have a query that works on its own but I am now trying to set a recordset equal to the query. Here is the vba code that I am using:

Dim db As Database, rs As DAO.Recordset, qdf As QueryDef, prm As Parameter

On Error GoTo Error_Handler
Set db = CurrentDb
Set qdf = db.QueryDefs("Query3")
For Each prm In qdf.Parameters
prm.value = Eval(prm.Name)
Next prm
Set rs = qdf.OpenRecordset(dbOpenDynaset)

I get the error on the last line of code.
Here is the sql statement for the query:

SELECT DISTINCT tblEquipOpReq.chrOpParam, tblEquipOpReq.dblLowRange, tblEquipOpReq.dblHighRange, tblEquipOpReq.idsRecord
FROM tblEquipLog INNER JOIN (tblEquipOpReq INNER JOIN tblEquipOpReqEvent ON tblEquipOpReq.idsRecord = tblEquipOpReqEvent.lngzRcrdID) ON tblEquipLog.idsRecord = tblEquipOpReqEvent.lngzRecordID
WHERE (((tblEquipLog.dtmDate)>[forms]![frmEquipLog]![dtmDate]-[tblEquipOpReq].[intFreq]) AND ((tblEquipOpReqEvent.lngzRecordID)=[forms]![frmEquipLog]![idsRecord]));


I believe it is the last line in the sql that is giving me problems: tblEquipOpReq.intFreq.
 
Last edited:
As stated before the query is working by itself but when I try to use it inside vba I get an error.

Are you able to use a field out of a table that you query as a parameter to the query? This is what I am doing with the [tblEquipOpReq].[intFreq].
 

Users who are viewing this thread

Back
Top Bottom