Sub CreateQueryDefX ()
Dim dbsNorthwind As Database
Dim qdfTemp As QueryDef
Dim qdfNew As QueryDef
The Set dbsNorthwind=OpenDatabase (" Northwind. MDB)
With dbsNorthwind
'Create temporary QueryDef.
The Set qdfTemp=. CreateQueryDef (", "_
"SELECT * FROM Employees")
'the Open you and print report.
GetrstTemp (qdfTemp)
'Create permanent QueryDef.
The Set qdfNew=. CreateQueryDef (" NewQueryDef, "_
"SELECT * FROM Categories")
'the Open you and print report.
GetrstTemp (qdfNew)
'Delete new QueryDef because this is a individual.
. QueryDefs. Delete qdfNew. Name
. Close
End With
End Sub
The code above is from MSDN copy down, run under the VS2010, added DAO3.6 reference, why the OpenDatabase (" Northwind. MDB), GetrstTemp (qdfTemp) tip error, not declare variables?