Urgent Help Needed!!

Geoff Codd

Registered User.
Local time
Today, 17:57
Joined
Mar 6, 2002
Messages
190
I've got the following piece of code, which will save a record, but if it is a duplicate it will comeback with a message, telling you to enter a different order number, the problem is that even when I change the number to one that is unique It keeps on giving the same error

Private Sub OrderSurveyNumber_AfterUpdate()
DoCmd.SetWarnings False
On Error Resume Next

If IsNull(Me![OrderSurveyNumber]) Then
Me!OrderSurveyNumber.Locked = False
Me!WorksOrderNumber.Enabled = False
Else
Me!OrderSurveyNumber.Locked = True
Me!WorksOrderNumber.Enabled = True
DoCmd.RunCommand acCmdSaveRecord
On Error GoTo Error_Message
End If

DoCmd.SetWarnings True

Error_Message:
MsgBox " The Order / Survey Number You Have Entered Belongs to Another Order."
Me!OrderSurveyNumber.Locked = False
Me!WorksOrderNumber.Enabled = False
Me!OrderSurveyNumber.SetFocus

End Sub

Any help is most welcome
Thanks
Geoff
 
after the statement :
Docmd.Setwarnings True

you need

Exit Sub

to avoid executing the Error_message:
 
Cheers Jacob.

It's always the smallest things that give you the most problems

Thanks
Geoff
 

Users who are viewing this thread

Back
Top Bottom