Update many records, each with a different criteria (1 Viewer)

Niroth

Registered User.
Local time
Today, 15:03
Joined
Jul 12, 2007
Messages
81
Hi,

So I'm trying to update different records, each to different value, each using a different criteria, but I want to do it all in one code. I tried something like this from a hidden form base on the table to be updated:

Code:
    Set myrcdst = Me.Recordset
    
With myrcdst
    Do Until .EOF
    DoCmd.RunSQL "DELETE * FROM " & Me.tblName _
    & " WHERE (((" & tblName & ".logTime)<#" & me.logTime & "#));"
    
    DoCmd.RunSQL "UPDATE dataTransferLog SET dataTransferLog.logTime = Now()" _
    & " WHERE (((dataTransferLog.tblName)= '" & Me.tblName & "'));"
        .MoveNext
    Loop
End With

Queries on run for the first record, but not the subsequent records. Tried putting in a gotorecord ,,acnext before the "loop", but still doesn't work. Does anyone know why? :confused:

Niroth
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 08:03
Joined
Jan 20, 2009
Messages
12,852
Change
Do Until .EOF
to
Do While Not .EOF

Another variant is:

Do
{more code}
Loop Until .EOF
 

Niroth

Registered User.
Local time
Today, 15:03
Joined
Jul 12, 2007
Messages
81
Thanks. :)
 

Users who are viewing this thread

Top Bottom