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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GoTo Record looping

Status
Not open for further replies.

sepia

Programmer
May 18, 2001
26
US
Easy newbie question. What is the most effective way of looping thru a query result set using "DoCmd.GoTo Record" object?
 
Actually, if you are going to loop through a recordset, why not use the MoveNext function of the recordset:
Code:
Public Function RemoveSpaces()
    Dim db As Database
    Dim rst As Recordset
    Dim stringin As String
    Dim pos As Integer
        
    Set db = CurrentDb
    Set rst = db.OpenRecordset("select * from RemoveSpaces")
    
    rst.MoveFirst
   
    Do While Not rst.EOF
    
        rst.Edit
        stringin = rst!string1
        
        Do While InStr(1, stringin, "  ")
            pos = InStr(1, stringin, "  ")
            stringin = Left(stringin, pos - 1) & " " & Mid(stringin, pos + 2)
        Loop
        
        rst!string2 = stringin
        rst.Update
        rst.MoveNext
       
    Loop
    
End Function
Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top