i abandoned the idea of INSERT query. here is how i worked it out.
I returned the filtered result in text boxes.
in a loop i copied theses results to another text boxes connected with ado wher i wanted to save them (booking table) and saved them.
- ..
-
Private Sub Cmdsave_Click()
-
-
Dim str1 As String
-
str1 = "select * from flt_availabale where fltno= '" & Text6 & "'AND fromcode >= " & CInt(Text11) & " And tocode <= " & CInt(Text12) & ""
-
Adofltavail.RecordSource = str1
-
Adofltavail.Refresh
-
Adofltavail.Recordset.MoveFirst
-
Do Until Adofltavail.Recordset.EOF
-
With Adobooking
-
.Recordset.Fields(0) = Text14.Text
-
.Recordset.Fields(1) = Text15.Text
-
.Recordset.Fields(2) = Text16.Text
-
.Recordset.Fields(3) = Text10.Text
-
.Recordset.Fields(4) = CInt(Text2.Text)
-
.Recordset.Fields(5) = Text9.Text
-
.Recordset.Save
-
.Recordset.Update
-
End With
-
Adofltavail.Recordset.MoveNext
-
Adobooking.Recordset.AddNew
-
Loop
-
Adopassenger.Recordset.Save
-
Adofltavail.Recordset.Close
-
Formfltavailable.Show
-
Formbooking.Visible = False
-
End Sub
-
-
..
There are many problems with this code. First of all you will overwrite the first record in booking with the values in the textboxes. Secondly you will continually add the same new record to booking depending on the number of rows returned from flt_available. Thirdly, and this might surprise you, the two recordsets appear to be global variables to which you are reassigning different data. This is definitely taboo in programming.
I tested the code from my previous posting. This works
-
strSQL = "INSERT INTO booking (flight, origin, destination) " _
-
& "SELECT fltno, fromcity, tocity " _
-
& "FROM flt_availabale " _
-
& "WHERE fltno = " & CInt(Formbooking.Text6.Text) & " " _
-
& "AND fromcode >= " & CInt(Formbooking.Text11.Text) & " " _
-
& "AND tocode <= " & CInt(Formbooking.Text12.Text)
-
.