P
PK
When I run the following code in an Access module (and in
V6, too) I get the following error.
The error occurs right near the end of the code. I've
indicated which line.
This is a simplified version of the original code. It
looks a bit pointless as it stands, but the intention in
the original code is to create two initially identical
recordsets. The first rs is directly bound to the source
data. The second rs is the one which users will change
(via a Data Grid). After some validation checks on the
changes, the changes to the second rs will be transferred
to the first rs (and therefore to the source data).
Thanks for your help.
PK
ERROR MESSAGE
Run-time error '3021':
Either BOF or EOF is True or the current record has been
deleted.
Requested operation requires a current record.
CODE
Dim rs1, rs2 As Recordset
Dim I As Integer
Set rs1 = New Recordset
Set rs2 = New Recordset
With rs1
.CursorLocation = adUseClient
.Fields.Append "Field0", adInteger
.Fields.Append "Field1", adVarChar, 40, adFldIsNullable
.Open , , adOpenDynamic, adLockOptimistic
For I = 1 To 10
.AddNew
.Fields(0) = I
.Fields(1) = Chr(64 + I)
.Update
Next I
.MoveFirst
For I = 1 To 10
.Find "[Field0] = " & I
Next
End With
With rs2
.CursorLocation = adUseClient
.Fields.Append "Field0", adInteger
.Fields.Append "Field1", adVarChar, 40, adFldIsNullable
.Open , , adOpenDynamic, adLockOptimistic
rs1.MoveFirst
Do While rs1.EOF = False
.AddNew
.Fields(0) = I
.Fields(1) = Chr(96 + I)
.Update
rs1.MoveNext
Loop
rs1.MoveFirst
Do While rs1.EOF = False
.Find "[Field0] = " & rs1("Field0")
MsgBox .Fields(0) & " - " & .Fields(1) '**ERROR**
Loop
End With
V6, too) I get the following error.
The error occurs right near the end of the code. I've
indicated which line.
This is a simplified version of the original code. It
looks a bit pointless as it stands, but the intention in
the original code is to create two initially identical
recordsets. The first rs is directly bound to the source
data. The second rs is the one which users will change
(via a Data Grid). After some validation checks on the
changes, the changes to the second rs will be transferred
to the first rs (and therefore to the source data).
Thanks for your help.
PK
ERROR MESSAGE
Run-time error '3021':
Either BOF or EOF is True or the current record has been
deleted.
Requested operation requires a current record.
CODE
Dim rs1, rs2 As Recordset
Dim I As Integer
Set rs1 = New Recordset
Set rs2 = New Recordset
With rs1
.CursorLocation = adUseClient
.Fields.Append "Field0", adInteger
.Fields.Append "Field1", adVarChar, 40, adFldIsNullable
.Open , , adOpenDynamic, adLockOptimistic
For I = 1 To 10
.AddNew
.Fields(0) = I
.Fields(1) = Chr(64 + I)
.Update
Next I
.MoveFirst
For I = 1 To 10
.Find "[Field0] = " & I
Next
End With
With rs2
.CursorLocation = adUseClient
.Fields.Append "Field0", adInteger
.Fields.Append "Field1", adVarChar, 40, adFldIsNullable
.Open , , adOpenDynamic, adLockOptimistic
rs1.MoveFirst
Do While rs1.EOF = False
.AddNew
.Fields(0) = I
.Fields(1) = Chr(96 + I)
.Update
rs1.MoveNext
Loop
rs1.MoveFirst
Do While rs1.EOF = False
.Find "[Field0] = " & rs1("Field0")
MsgBox .Fields(0) & " - " & .Fields(1) '**ERROR**
Loop
End With