C
cjg.groups
I am having problems creating a QueryDef object to store the SQL
statement that I'm building in VB. This must be a simple syntax
problem. Here are excerpts of my code:
Dim qdfMake As DAO.QueryDef
Dim strSQL As String
strSQL = "SELECT Orders.OrderID, "
' use conditionals to finish building strSQL
Set qdfMake = New DAO.QueryDef
' Set qdfMake = db.QueryDefs("qryOutputReport_calcs")
qdfMake.SQL = strSQL
qdfMake.Parameters(0) = Eval(strCtlOID)
qdfMake.Execute
The statement is assigned to .SQL, as shown by "Debug.Print
qdfMake.SQL". But the .Parameters line fails, saying something's not
in the collection. Commenting that line out, the Execute line fails
saying the object doesn't exist (error 91).
I tried to reuse a properly created qdfMake by commenting my Set line
and uncommenting the one below. The Execute line failed claiming it
didn't have enough parameters (the built query depends on a form
control), so maybe the object is ok. But oddly, now a QueryDef and
RecordSet earlier in my code have failed.......
Any ideas for simply creating an object? Thanks.
statement that I'm building in VB. This must be a simple syntax
problem. Here are excerpts of my code:
Dim qdfMake As DAO.QueryDef
Dim strSQL As String
strSQL = "SELECT Orders.OrderID, "
' use conditionals to finish building strSQL
Set qdfMake = New DAO.QueryDef
' Set qdfMake = db.QueryDefs("qryOutputReport_calcs")
qdfMake.SQL = strSQL
qdfMake.Parameters(0) = Eval(strCtlOID)
qdfMake.Execute
The statement is assigned to .SQL, as shown by "Debug.Print
qdfMake.SQL". But the .Parameters line fails, saying something's not
in the collection. Commenting that line out, the Execute line fails
saying the object doesn't exist (error 91).
I tried to reuse a properly created qdfMake by commenting my Set line
and uncommenting the one below. The Execute line failed claiming it
didn't have enough parameters (the built query depends on a form
control), so maybe the object is ok. But oddly, now a QueryDef and
RecordSet earlier in my code have failed.......
Any ideas for simply creating an object? Thanks.