validate in text box

  • Thread starter Thread starter alejandro
  • Start date Start date
A

alejandro

I have two textbox unbound
one named BEGIN and another named END

i want to make beforeupdate if the value of END < BEGIN the cursor come to
the textbox END and dont advance to next textbox and display a message" the
ende value must be bigger than BEGIN"

Thanks in advance

Alejandro Carnero
 
alejandro said:
I have two textbox unbound
one named BEGIN and another named END

i want to make beforeupdate if the value of END < BEGIN the cursor
come to the textbox END and dont advance to next textbox and display
a message" the ende value must be bigger than BEGIN"

Thanks in advance

Alejandro Carnero

It's pretty straightforward, I think, except that you have to watch out
for the case where BEGIN is Null. Also, your names "BEGIN" and "END"
are bad choices; "END", at least, is a VBA statement, and "BEGIN" is
probably used for something, somewhere, that you want to be sure not to
conflict with.

Suppose you use the names "txtBegin" and "txtEnd" instead. Then you
might write:

'---- start of example code ----
Private Sub txtEnd_BeforeUpdate(Cancel As Integer)

If Not IsNull(Me.txtEnd) Then

If Not IsNull(Me.txtBegin) Then

If Me.txtEnd < Me.txtBegin Then
MsgBox "End must be >= Begin!"
Cancel = True
End If

End If

End If

End Sub
'---- end of example code ----
 
Back
Top