Data Validation in a text field

Doozer1979

Registered User.
Local time
Today, 17:41
Joined
Jul 4, 2007
Messages
32
Hi Guys,

I need to validate text entered into a text box using VBA.

The text that will be entered needs to conform to the following criteria:

1. L[000], where [000] can be any number between 00 and 999
2. L[A][] where [A] can be be any letter of the alphabet, and [000] can be any number between 00 and 999
3. TD[000] where [000] can be any number between 00 and 999
4. AX[000] where [000] can be any number between 00 and 999

I'm assuming this would need to be placed in the OnExit or AfterUpdate events, but i'm having difficulty in getting even the most basic validation to work.


I'm using the following code just to test some basic validation, but i would like any errors to be displayed in a vbok message box.

If Me.txtCallSign.Value Like "L50" Then
Debug.Print "great"
Else: Debug.Print "error"
End If

Your help is greatly appreciated.
 
One tip may be to do the validation using one of the str functions e.g. Left : Right : Mid : or instr.

From what you have written, it looks like you are going to have to break down the original textbox entry into its component parts and then validate those. If each test passes then you are OK. Any fail with be data that does not conform.
 
Sounds a bit complicated for my level at the moment!


Thanks for the suggestion. It's not urgent so i 'll come back to it in a couple of weeks when i've leant some more VBA.
 

Users who are viewing this thread

Back
Top Bottom