How to do an APPEND QRY

B

Ben

I have a table that I had a field "archive" (YES/NO) and I want to update it
depending the value of another field "Tstat" in the same table.

I did it with VISUAL BASIC codes as follow :

Dim DB1 As ADODB.Connection
Set DB1 = CurrentProject.Connection

Dim RS1 As New ADODB.Recordset

RS1.Open "Board_Data", DB1, adOpenStatic, adLockPessimistic
RS1.MoveFirst
Do Until RS1.EOF
If RS1!Tstat = 14 Then
RS1!archive = true
End If
RS1.MoveNext
Loop
RS1.Close
End Sub

Problem is I have an error message "maxlocksperfile" to increase...

Is there an easiest way to do this with an APPEND or UPDATE QRY ?
 
D

Douglas J. Steele

It's almost always more efficient to use SQL, rather than looping through a
recordset.

All you need is "UPDATE Board_Data SET Archive = True WHERE Tstat = 14"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top