W
wentex
I want to change the SQL for a query based on input parameters in a macro.
Can anyone tell me why VBA gives me the Compile Error "User-defined type not
defined" for variable qdf? Everything I've read indicates that QueryDef
should be a valid type, but my system doesn't seem to know it. Should I be
using AccessObject (or something like it) instead? Here's my code:
Sub sCreateSQL()
Dim qdf As QueryDef
Dim strSQL, strFromDate, strToDate, tmpQuery As String
tmpQuery = "QryTemp"
strFromDate = gblYrMo & "00"
strToDate = gblYrMo & "99"
strSQL = "SELECT * FROM tblOne WHERE ((tblOne.Dt>""" & strFromDate &
""") and (tblOne.Dt<""" & strToDate & """));"
qdf = CurrentDb.CreateQueryDef(tmpQuery, strSQL)
qdf.SQL = strSQL
End Sub 'sCreateSQL
Thanks!
Can anyone tell me why VBA gives me the Compile Error "User-defined type not
defined" for variable qdf? Everything I've read indicates that QueryDef
should be a valid type, but my system doesn't seem to know it. Should I be
using AccessObject (or something like it) instead? Here's my code:
Sub sCreateSQL()
Dim qdf As QueryDef
Dim strSQL, strFromDate, strToDate, tmpQuery As String
tmpQuery = "QryTemp"
strFromDate = gblYrMo & "00"
strToDate = gblYrMo & "99"
strSQL = "SELECT * FROM tblOne WHERE ((tblOne.Dt>""" & strFromDate &
""") and (tblOne.Dt<""" & strToDate & """));"
qdf = CurrentDb.CreateQueryDef(tmpQuery, strSQL)
qdf.SQL = strSQL
End Sub 'sCreateSQL
Thanks!