G
Guest
in an exit event, I check the field value, if something wrong with the data
entered, I need to set the focus stayed at the control until user entered a
valid data, I wrote like this:
Private Sub SetNum1_Exit(Cancel As Integer)
Dim Brandcd As Variant
Dim Bcdstr As String
If Not IsNull(Forms!test!SetNum1) Then
Brandcd = DLookup("SegmentCode", "dbo_Item", "[ItemNumber] =
Forms!test!SetNum1")
If Not IsNull(Brandcd) Then
Bcdstr = Brandcd
If Bcdstr <> Forms!test!SegmentCode Then
Forms!test!SetNum1.BackColor = 16751052
MsgBox ("Segment Code is not consistent")
Forms!test!SetNum1.SetFocus
Exit Sub
End If
End If
End If
End Sub
but after the event, the focus still moves on to the next control, how can I
keep it?
any help would be great, thanks a lot in advance!
entered, I need to set the focus stayed at the control until user entered a
valid data, I wrote like this:
Private Sub SetNum1_Exit(Cancel As Integer)
Dim Brandcd As Variant
Dim Bcdstr As String
If Not IsNull(Forms!test!SetNum1) Then
Brandcd = DLookup("SegmentCode", "dbo_Item", "[ItemNumber] =
Forms!test!SetNum1")
If Not IsNull(Brandcd) Then
Bcdstr = Brandcd
If Bcdstr <> Forms!test!SegmentCode Then
Forms!test!SetNum1.BackColor = 16751052
MsgBox ("Segment Code is not consistent")
Forms!test!SetNum1.SetFocus
Exit Sub
End If
End If
End If
End Sub
but after the event, the focus still moves on to the next control, how can I
keep it?
any help would be great, thanks a lot in advance!