A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How to do an APPEND QRY



 
 
Thread Tools Display Modes
  #1  
Old October 4th, 2006, 08:02 PM posted to microsoft.public.access.forms
Ben
external usenet poster
 
Posts: 7
Default How to do an APPEND QRY

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 ?



  #2  
Old October 4th, 2006, 08:43 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default How to do an APPEND QRY

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"

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ben" wrote in message ...
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 ?





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:59 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.