Hi: I've copied and pasted the following code from a previous forum which answers most of my question, specifically, how do you create/Change an Access Query through VB. The part I'm stuck on is the qdl.sql which contains the query itself. In the following code; how do you assign the query in Access as the qdl.sql string.
*******************************************************
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
'Create the new record set based on our new SELECT statement
Set dbs = OpenDatabase(App.Path & "\safety.mdb"
'Delete the old query
dbs.QueryDefs.Delete "ReportQuery"
'Recreate the query with the new criteria
Set qdf = dbs.CreateQueryDef("ReportQuery"
qdf.SQL = "SELECT * FROM " & TABLE & strCriteria & " ORDER BY Year, Month ;"
'Open the query recordset
Set rst = dbs.OpenRecordset("ReportQuery"
Of course, your "qdf.SQL" statement will be the SQL that creates the query you are looking for.
****************************************************
This last paragraph; how do I accomplish that???
Thank you.
*******************************************************
Dim dbs As Database
Dim rst As Recordset
Dim qdf As QueryDef
'Create the new record set based on our new SELECT statement
Set dbs = OpenDatabase(App.Path & "\safety.mdb"
'Delete the old query
dbs.QueryDefs.Delete "ReportQuery"
'Recreate the query with the new criteria
Set qdf = dbs.CreateQueryDef("ReportQuery"
qdf.SQL = "SELECT * FROM " & TABLE & strCriteria & " ORDER BY Year, Month ;"
'Open the query recordset
Set rst = dbs.OpenRecordset("ReportQuery"
Of course, your "qdf.SQL" statement will be the SQL that creates the query you are looking for.
****************************************************
This last paragraph; how do I accomplish that???
Thank you.