Copying all rows from basketContent to basketsContent

  • Thread starter Thread starter h3llz
  • Start date Start date
H

h3llz

If QryDat.BOF = False And QryDat.EOF = False Then
QryDat.MoveFirst

Part of my script, but i dont know how to loop to get all the rows in
basketContent, how can i find out how many rows returned ?
 
On Wed, 10 Dec 2008 02:37:00 -0800, h3llz

IMO copying data is best done with an Append query that takes
parameter(s).

If you insist in doing it with recordsets:
dim rsFrom as dao.recordset
dim rsTo as dao.recordset
set rsFrom = Currentdb.OpenRecordset(...)
set rsTo = Currentdb.OpenRecordset(...)
while not rsFrom.EOF
rsTo.AddNew
rsTo!SomeField = rsFrom!SomeField
rsTo!OtherField = rsFrom!OtherField
'etc.
rsTo.Update
rsFrom.MoveNext
wend
'Todo: close objects.

-Tom.
Microsoft Access MVP
 
how can i find out how many rows returned ?

Either

qryDAT.MoveLast
Debug.Print qryDat.RecordCount

or

Debug.Print DCount("*", "qryDat") <without opening the query at all>
 
Tom, will your air code copy from one table/form to another table/form. I'm
not very experienced with code like this, but need a solution for the above
scenario.

I tried to modify your code, but it threw an 'Object Required 424' error on
the 'Set rsFrom' line in the code below:

My full code:

Private Sub btn_Reveal_Run_Timer_Click()
'On Error GoTo Proc_Err


Dim rsFrom As dao.Recordset
Dim rsTo As dao.Recordset
'set rsFrom = Currentdb.OpenRecordset(...)

Set rsFrom = db.OpenRecordset("Select
me.frm_Run_Reveal_Selector.Run_waypoint from tbl_Run_Reveal_Selector where
[Run_No]=" & Forms!frm_Runs![Run_No] & " order by [Run_waypoint_List_ID];",
dbOpenForwardOnly)


Set rsTo = db.OpenRecordset("Select [Run_waypoint] from
tbl_Run_Reveal_Target where [Run_No]=" & lngRunNo & " order by
[Run_waypoint_List_ID];", dbOpenForwardOnly)

'set rsTo = Currentdb.OpenRecordset(...)
While Not rsFrom.EOF
rsTo.AddNew
rsTo!Run_waypoint = rsFrom!Run_waypoint
rsTo!Run_Direction = rsFrom!Run_Direction

' rsTo!SomeField = rsFrom!SomeField
' rsTo!OtherField = rsFrom!OtherField
'etc.
rsTo.Update
rsFrom.MoveNext
Wend
Todo: Close objects

End Sub
 
Back
Top