A
aydin
I am trying to build a pass-through query which is
supposed to pull criteria that the user enters in a form.
As far as I know, a pass-through query cannot interact
with Jet and therefore it cannot refer to a field in a
form. To overcome this problem, I wrote the following code
using QueryDef, but I was not able to make this code work.
It does not give an error, but it does not bring up any
records either. Can you tell me what I am missing or where
I am making a mistake?
......
Private Sub Command70_Click()
Dim MyDb As DAO.Database, MyQry As QueryDef, MyRS As
DAO.Recordset
Set MyDb = CurrentDb()
Set MyQry = MyDb.CreateQueryDef("")
MyQry.SQL = "select flight_id, flight_date from
flight_table where flight_number = " & [Forms]![Retrieve
Forecasts]![Enter Flight Number]
MyQry.ReturnsRecords = True
Set MyRS = MyQry.OpenRecordset()
MyRS.MoveFirst
Debug.Print MyRS!flight_id, MyRS!flight_date
MyQry.Close
MyRS.Close
MyDb.Close
End Sub
supposed to pull criteria that the user enters in a form.
As far as I know, a pass-through query cannot interact
with Jet and therefore it cannot refer to a field in a
form. To overcome this problem, I wrote the following code
using QueryDef, but I was not able to make this code work.
It does not give an error, but it does not bring up any
records either. Can you tell me what I am missing or where
I am making a mistake?
......
Private Sub Command70_Click()
Dim MyDb As DAO.Database, MyQry As QueryDef, MyRS As
DAO.Recordset
Set MyDb = CurrentDb()
Set MyQry = MyDb.CreateQueryDef("")
MyQry.SQL = "select flight_id, flight_date from
flight_table where flight_number = " & [Forms]![Retrieve
Forecasts]![Enter Flight Number]
MyQry.ReturnsRecords = True
Set MyRS = MyQry.OpenRecordset()
MyRS.MoveFirst
Debug.Print MyRS!flight_id, MyRS!flight_date
MyQry.Close
MyRS.Close
MyDb.Close
End Sub