validate in text box

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
 
D

Dirk Goldgar

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 ----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top