Any help with this is appreciated, I'm treading new territory here:
I am creating a QueryDef object so that I can dynamically build a simple select statement using a value entered on a form as the field to return. It builds my SQL statement just fine (as I see in the MsgBox display). It produces:
SELECT WkndAbs_Small.[02/12/05]
FROM WkndAbs_Small;
But, when it tries to execute the query it asks for the user to 'Enter Parameter Value'.
I am using the following code:
'*** Create QueryDef Object with SQL
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL =
"SELECT WkndAbs_Small.[" & Forms!WeekendDatesEntry!SAT1_ENTRY & "] FROM WkndAbs_Small"
MsgBox (strSQL)
Set qdf = dbs.CreateQueryDef("Sat1 Test", strSQL)
'*** Execute SQL Statement
Dim stDocName As String
stDocName = "Sat1 Test"
DoCmd.OpenQuery stDocName, acNormal, acEdit
The value from SAT1_ENTRY on the WeekendDatesEntry form is the field name for the table WkndAbs_Small (the field name is a date value). The CreateQueryDef creates it As Expr1, thereby wanting a parameter?
If I execute it manually, it works just fine. Please help if you can! Thanks!
I am creating a QueryDef object so that I can dynamically build a simple select statement using a value entered on a form as the field to return. It builds my SQL statement just fine (as I see in the MsgBox display). It produces:
SELECT WkndAbs_Small.[02/12/05]
FROM WkndAbs_Small;
But, when it tries to execute the query it asks for the user to 'Enter Parameter Value'.
I am using the following code:
'*** Create QueryDef Object with SQL
Dim dbs As Database, qdf As QueryDef, strSQL As String
Set dbs = CurrentDb
strSQL =
"SELECT WkndAbs_Small.[" & Forms!WeekendDatesEntry!SAT1_ENTRY & "] FROM WkndAbs_Small"
MsgBox (strSQL)
Set qdf = dbs.CreateQueryDef("Sat1 Test", strSQL)
'*** Execute SQL Statement
Dim stDocName As String
stDocName = "Sat1 Test"
DoCmd.OpenQuery stDocName, acNormal, acEdit
The value from SAT1_ENTRY on the WeekendDatesEntry form is the field name for the table WkndAbs_Small (the field name is a date value). The CreateQueryDef creates it As Expr1, thereby wanting a parameter?
If I execute it manually, it works just fine. Please help if you can! Thanks!