Hi, i have a form that users will use to add new records (customers).
there is a field named VAT_Registration_no
first of all i want some code to check for duplicates in that field only,before entering the next field.If the record exists i want to show a msgbox and set focus to the vat_registration_no field.Also i want the same thing to happen if the vat_registration_no field is empty.here is what i have tried:
Private Sub VAT_registration_no_AfterUpdate()
Dim btest As Boolean
If VAT_registration_no = "" Or IsNull(Me.VAT_registration_no) Then
MsgBox "Please enter a Vat Registration No.", vbOKOnly, "error"
Me.VAT_registration_no.SetFocus
Else
btest = True
End If
End Sub
and to all other fields:
Private Sub textfield_Enter()
If Not btest Then
Me.textfield.SetFocus
End If
End Sub
if i just press enter to go straight to the second field i dont get a msg.if i write something and delete it and press enter i get the msg but when i press ok the cursor goes to the next field.i want it to go to the vat_registration_no field again.and i also want this to happen even if dont write something and then delete it.i hope you understand what i want
thanks in advance
there is a field named VAT_Registration_no
first of all i want some code to check for duplicates in that field only,before entering the next field.If the record exists i want to show a msgbox and set focus to the vat_registration_no field.Also i want the same thing to happen if the vat_registration_no field is empty.here is what i have tried:
Private Sub VAT_registration_no_AfterUpdate()
Dim btest As Boolean
If VAT_registration_no = "" Or IsNull(Me.VAT_registration_no) Then
MsgBox "Please enter a Vat Registration No.", vbOKOnly, "error"
Me.VAT_registration_no.SetFocus
Else
btest = True
End If
End Sub
and to all other fields:
Private Sub textfield_Enter()
If Not btest Then
Me.textfield.SetFocus
End If
End Sub
if i just press enter to go straight to the second field i dont get a msg.if i write something and delete it and press enter i get the msg but when i press ok the cursor goes to the next field.i want it to go to the vat_registration_no field again.and i also want this to happen even if dont write something and then delete it.i hope you understand what i want
