Another "Couldn't Update, Currently Locked" err

N

ndunwoodie

Mine occurs when the code below is excuted. The button searches for records
marked with an "X" in one of the fields. When an "X" is encountered, a date
field is incremented and the "X" is erased. Any thoughts?

Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Dim rst As New ADODB.Recordset, strSQL As String, i As Integer, SLDate As
Date, strName As String, varAbs As Variant
rst.Open "tblSilTrans", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rst
Do Until (.EOF)
strName = ![txtName]
SLDate = ![datStartDate]
varAbs = Nz(![txtAbs])
If varAbs = UCase("x") Then
SLDate = DateAdd("d", 1, SLDate)
SLDate = SLD(SLDate) ' function to make sure SLDate is not a
weekend or holiday
![datStartDate] = SLDate
![txtAbs] = " "
End If

.MoveNext
Loop
End With
rst.Close
Set rst = Nothing

Exit_cmdSubmit_Click:
Exit Sub

Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click

End Sub
 
D

Dirk Goldgar

ndunwoodie said:
Mine occurs when the code below is excuted. The button searches for
records marked with an "X" in one of the fields. When an "X" is
encountered, a date field is incremented and the "X" is erased. Any
thoughts?

Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Dim rst As New ADODB.Recordset, strSQL As String, i As Integer,
SLDate As Date, strName As String, varAbs As Variant
rst.Open "tblSilTrans", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
With rst
Do Until (.EOF)
strName = ![txtName]
SLDate = ![datStartDate]
varAbs = Nz(![txtAbs])
If varAbs = UCase("x") Then
SLDate = DateAdd("d", 1, SLDate)
SLDate = SLD(SLDate) ' function to make sure SLDate is
not a weekend or holiday
![datStartDate] = SLDate
![txtAbs] = " "
End If

.MoveNext
Loop
End With
rst.Close
Set rst = Nothing

Exit_cmdSubmit_Click:
Exit Sub

Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click

End Sub

Where's your call to the recordset's .Update method?
 

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