gusbrunston
Programmer
Hi:
In a manual on VB and two manuals on Access2000, and in Help, I'm having trouble finding a reference to "RS.Edit" and "RS.Update".
Below is a snippet of code from a function that works great...but I need to lock the records while they're being edited...
Does "RS.Edit" lock the record being edited? and does "RS.Update" unlock it?
If I didn't use RS.Edit and RS.Update, would the record be edited and updated anyway (through the SQL statement not shown below)?
I've put this code in so that you can more easily see what I'm about:
[tt]Function....
Set db = CurrentDb()
Set RS = db.OpenRecordset(SQL, dbOpenDynaset)
If RS.RecordCount = 0 Then
‘if no records, close and exit
RS.Close
GoTo Exit1
End If
If RS!BeginBalance > 0 Then
‘accounts in existence before implementation
‘have a balance from the old system
CurBB = RS!BeginBalance
Else
‘new accounts have no beginning balance
CurBB = 0
End If
‘Does this lock the first record?
RS.Edit
RS!Balance = CurBB - RS!PayAmount + RS!DepAmount
‘Does this unlock the first record?
RS.Update
CurDB = RS!Balance
RS.MoveNext
Do Until RS.EOF
RS.Edit ‘again: will this lock the record?
RS!Balance = CurDB - RS!PayAmount + RS!DepAmount
RS.Update ‘and again, unlock the record?
CurDB = RS!Balance
RS.MoveNext
Loop
RS.Close
db.Close
....
End Function
[/tt]
Thanks for your help, and/or pointing me in the right direction.
Gus Brunston
An old PICKer, using Access2000
[tt]Want solutions you can understand?
Post understandable questions.[/tt]
In a manual on VB and two manuals on Access2000, and in Help, I'm having trouble finding a reference to "RS.Edit" and "RS.Update".
Below is a snippet of code from a function that works great...but I need to lock the records while they're being edited...
Does "RS.Edit" lock the record being edited? and does "RS.Update" unlock it?
If I didn't use RS.Edit and RS.Update, would the record be edited and updated anyway (through the SQL statement not shown below)?
I've put this code in so that you can more easily see what I'm about:
[tt]Function....
Set db = CurrentDb()
Set RS = db.OpenRecordset(SQL, dbOpenDynaset)
If RS.RecordCount = 0 Then
‘if no records, close and exit
RS.Close
GoTo Exit1
End If
If RS!BeginBalance > 0 Then
‘accounts in existence before implementation
‘have a balance from the old system
CurBB = RS!BeginBalance
Else
‘new accounts have no beginning balance
CurBB = 0
End If
‘Does this lock the first record?
RS.Edit
RS!Balance = CurBB - RS!PayAmount + RS!DepAmount
‘Does this unlock the first record?
RS.Update
CurDB = RS!Balance
RS.MoveNext
Do Until RS.EOF
RS.Edit ‘again: will this lock the record?
RS!Balance = CurDB - RS!PayAmount + RS!DepAmount
RS.Update ‘and again, unlock the record?
CurDB = RS!Balance
RS.MoveNext
Loop
RS.Close
db.Close
....
End Function
[/tt]
Thanks for your help, and/or pointing me in the right direction.
Gus Brunston
![[glasses] [glasses] [glasses]](/data/assets/smilies/glasses.gif)
[tt]Want solutions you can understand?
Post understandable questions.[/tt]