hello-
i received an runtime error message: You tried to call Update or
CancelUpdate or attempted to update a Field in a recordset without
first calling AddNew or Edit. (Error 3020). when i look through my
code again, i thought that i called the Edit methode before i tried to
update the [DBInUse] field.
thanks in advance, jung
here is the following code:
Dim rst, rst2, rstmySQL As Recordset
Dim db As Database
Dim mysSQL As String
Set db = CurrentDb
Set rst = db.OpenRecordset("DailyCreateExceptionReport")
Set rst2 = db.OpenRecordset("DBInUse")
'Locks the database so that others cannot add more loans to the record
set while running the AutoCreator
Do Until rst.EOF
If rst![CreatedMoved] = True Then
'look up the database for the loan to be created.
If rst![Database] = rst2![DBName] Then
With rst
.Edit
![DBInUse] = True 'Object variable or Width block
variable not set error
.Update
End With
Else
rst2![DBInUse] = False
End If
Else
With rst2
.Edit
![DBInUse] = False
.Update
End With
End If
'x = x + 1
rst.MoveNext
Loop
If rst2![DBInUse] = True Then 'yes
MsgBox "The AutoCreator feature cannot run due to a sharing
voilation." & (Chr(13) & Chr(10)) & _
"Another user is running the CREA*18/MOVE*18 in the
selected database." & (Chr(13) & Chr(10)) & _
"Please select another database to use the AutoCreator
feature.", vbCritical
Else
Forms![F-Main]![WorkWindow].SourceObject = "Plate_AutoCreator"
End If
Set rst = Nothing
Set rst2 = Nothing
Set db = Nothing