What I am trying to do is call the first query string (MyQuery1) that has been created within the second query string (MyQuery2). So as shown below in MyQuery2 I want to use the previous recordsets results (rst2) in the SQL string rather than a named table or query. Is this or something similar possible?
Many thanks...
Dim db As dao.Database
Dim rst1 As dao.Recordset
Dim rst2 As dao.Recordset
Dim MyQuery1 As String
Dim MyQuery2 As String
Set db = CurrentDb()
MyQuery1 = "SELECT sf_booking.FirstName, one.Booking_ID, one.First, one.Last " & _
"FROM sf_booking INNER JOIN one ON sf_booking.BookingID = one.Booking_ID " & _
"WHERE (((sf_booking.FirstName)='" & Me.txtName.Value & "'));"
Set rst1 = db.OpenRecordset(MyQuery1)
MyQuery2 = "Select * from " & rst1 & " Where First = 'Bill'"
Set rst2 = db.OpenRecordset(MyQuery2)
rst2.MoveFirst
Many thanks...
Dim db As dao.Database
Dim rst1 As dao.Recordset
Dim rst2 As dao.Recordset
Dim MyQuery1 As String
Dim MyQuery2 As String
Set db = CurrentDb()
MyQuery1 = "SELECT sf_booking.FirstName, one.Booking_ID, one.First, one.Last " & _
"FROM sf_booking INNER JOIN one ON sf_booking.BookingID = one.Booking_ID " & _
"WHERE (((sf_booking.FirstName)='" & Me.txtName.Value & "'));"
Set rst1 = db.OpenRecordset(MyQuery1)
MyQuery2 = "Select * from " & rst1 & " Where First = 'Bill'"
Set rst2 = db.OpenRecordset(MyQuery2)
rst2.MoveFirst