B
bamboo
Guest
I try to do MoveLast after delete a record from the database, but there is an error saying that, "Either EOF or BOF is true.The Current record has been deleted"..... Below is the code
code:
____________________________________________________
Dim RS As New ADODB.Recordset
Set RS = Adodc1.Recordset
CON.Open Adodc1.ConnectionString
RS.Open "Select POID, VendNo,CStatus,Currency, comment,ShipVia, FOB, Freight, ConfirmTo, " & _
"Dept, Remark, PODate, HDay, HMonth, HYear, CustName, CustLoc, " & _
"CustAddr, Disc, Netday, RegNo From PO " & _
"Where POID=" & Trim(Me.txtF(20).Text) & "", CON, adOpenKeyset, adLockOptimistic
With RS
.MoveFirst
.Find ("POID=" & Trim(Me.txtF(20).Text) & "")
.Delete
.moveNext
If .EOF Then
.MoveLast
text1.text=RS![POID] <---- (Error is here)
End If
.Close
.Open "delete * from POBody where POID=" & Trim(Me.txtF(20).Text) & ""
End With
Set CON = Nothing
Set RS = Nothing
End Sub
______________________________________________________
What is wrong with my code?
code:
____________________________________________________
Dim RS As New ADODB.Recordset
Set RS = Adodc1.Recordset
CON.Open Adodc1.ConnectionString
RS.Open "Select POID, VendNo,CStatus,Currency, comment,ShipVia, FOB, Freight, ConfirmTo, " & _
"Dept, Remark, PODate, HDay, HMonth, HYear, CustName, CustLoc, " & _
"CustAddr, Disc, Netday, RegNo From PO " & _
"Where POID=" & Trim(Me.txtF(20).Text) & "", CON, adOpenKeyset, adLockOptimistic
With RS
.MoveFirst
.Find ("POID=" & Trim(Me.txtF(20).Text) & "")
.Delete
.moveNext
If .EOF Then
.MoveLast
text1.text=RS![POID] <---- (Error is here)
End If
.Close
.Open "delete * from POBody where POID=" & Trim(Me.txtF(20).Text) & ""
End With
Set CON = Nothing
Set RS = Nothing
End Sub
______________________________________________________
What is wrong with my code?