Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop Until gets to last record

Status
Not open for further replies.

dead7

Programmer
Jun 8, 2004
79
US
How do I say Loop Until I get to last record, I want to loop thru the records copying and pasting in to other app and stop when it gets to the last record
I have this

Dim stAppName As String
Dim lngRetval As Long
Dim dblRandomVariable As Double
dblRandomVariable = Shell(stAppName, 1)


stAppName = "C:\Documents and Settings\023Q\Desktop\MASLine.exe"

Do
Forms![frmClaimHead-Line_RR]![frmMASline_RR subform].SetFocus
DoCmd.GoToControl "claimline"
DoCmd.RunCommand acCmdCopy


Call dblRandomVariable
DoCmd.GoToRecord , , acNext

'Call ClearClipboard
Loop Until lastrecord
 
You could use the RecordsetClone:
Code:
Dim rs As DAO.Recordset

Set rs = Me.RecordsetClone

'Go to first record and synchronise form with recordset
'You can do this the other way round, if you wish
'to copy from "here" on, that is
'rs.Bookmark = Me.Bookmark

rs.MoveFirst
Me.Bookmark = rs.Bookmark

    Do While Not rs.EOF
         Forms![frmClaimHead-Line_RR]![frmMASline_RR 'subform].SetFocus
         DoCmd.GoToControl "claimline"
         DoCmd.RunCommand acCmdCopy
         
         Call dblRandomVariable

         rs.MoveNext
         If rs.EOF Then Exit Sub

         Me.Bookmark = rs.Bookmark
 
        Call ClearClipboard
     Loop 'Until lastrecord
 
I am using ado access 2003, dao will not work I keep getting errors on that part
 
You need to add a reference to the DAO library. In a module window, select Tools->References and tick the little box for Microsoft DAO x.x Object Library.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top