leeckeat
Aug 15th, 2000, 09:07 PM
here is the my edit coding but it have minor problem where when i edit the existing data which i put empty on data field (customer name), it suppose to show me error message.
But when i run it, it will display the 'record edited' message before showing me the error message. What part is wrong in my code? need ur guide..TQ
On Error GoTo EditErr
'Open customer recordset to save edited record
Set rstTemp = Db.OpenRecordset("Select * from Customer", dbOpenDynaset)
With rstTemp
Do While Not .EOF
.Edit
If !CustomerCode = txtDisplay1.Text Then
!CustomerName = txtDisplay2.Text
MsgBox "Record Edited", vbOKOnly, "Customer"
End If
.Update
.MoveNext
Loop
End With
txtDisplay1.Text = ""
txtDisplay2.Text = ""
EditErr:
If Err.Number = 3315 Then
MsgBox "Data field can't be empty, please try again!",
vbOKOnly + vbCritical, "Error Message"
End If
But when i run it, it will display the 'record edited' message before showing me the error message. What part is wrong in my code? need ur guide..TQ
On Error GoTo EditErr
'Open customer recordset to save edited record
Set rstTemp = Db.OpenRecordset("Select * from Customer", dbOpenDynaset)
With rstTemp
Do While Not .EOF
.Edit
If !CustomerCode = txtDisplay1.Text Then
!CustomerName = txtDisplay2.Text
MsgBox "Record Edited", vbOKOnly, "Customer"
End If
.Update
.MoveNext
Loop
End With
txtDisplay1.Text = ""
txtDisplay2.Text = ""
EditErr:
If Err.Number = 3315 Then
MsgBox "Data field can't be empty, please try again!",
vbOKOnly + vbCritical, "Error Message"
End If