Validate info in Textbox

M

Matt Weyland

I have a form with two text boxes, which are storing
strings. One called year and another called Number. The
year is a two character field and is to be captured YY for
the last two digits of the year and zero place holder.
i.e. 02, 03, 04. The other field is the same situation
but storing the number of a memo i.e. 003, 121, 054. I
want to keep the length of the field three characters
regardless but want to ensure that numbers in the correct
format are being entered. Does anyone have any ideas on
how to go about doing this?

Thanks in advance.

responses can be sent to

mjweyland at yahoo dotcom
 
T

Tim

Something like this...

In the Before Update event of the Year field:

If Len(Me.Year) > 2 Or Not IsNumeric(Me.Year) Then
MsgBox "Please enter a valid two digit year"
Cancel = True
End If

In the Before Update event of the Number field:

If Len(Me.Number) > 3 Or Not IsNumeric(Me.Number) Then
MsgBox "Please enter a valid three digit number"
Cancel = True
End If

Tim
 

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