473,466 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Validation Rules: Letter and Number Validation

14 New Member
Hello all, and thanks for taking the time to help me out here.

Basically, I am trying to set up a validation rule that correlates with an input mask where the user is required to enter select alpha characters followed by a series of numeric characters.

The input mask Auto-enters API, requires an alpha value in upper case, and up to 8 numeric values., as seen here:

"API"<L99999999

Now, the part I am having trouble with is setting up the validation rule. I need for it to check and make sure that either "M" or "A" have been entered following the auto entered "API". The validation rule (as seen below) will do that, but no matter how much I mess with it I can't seem to get it to allow between 1 and 8 numeric values to be entered following the "M" or "A". Values like APIA1234 (or APIM1234) should be accepted just as APIA12345678 (or API12345678) would.

Here is the validation rule so far:
"API" & "" & "M" Or "A"

Again, thanks guys!
Jun 21 '07 #1
6 11021
puppydogbuddy
1,923 Recognized Expert Top Contributor
Hello all, and thanks for taking the time to help me out here.

Basically, I am trying to set up a validation rule that correlates with an input mask where the user is required to enter select alpha characters followed by a series of numeric characters.

The input mask Auto-enters API, requires an alpha value in upper case, and up to 8 numeric values., as seen here:

"API"<L99999999

Now, the part I am having trouble with is setting up the validation rule. I need for it to check and make sure that either "M" or "A" have been entered following the auto entered "API". The validation rule (as seen below) will do that, but no matter how much I mess with it I can't seem to get it to allow between 1 and 8 numeric values to be entered following the "M" or "A". Values like APIA1234 (or APIM1234) should be accepted just as APIA12345678 (or API12345678) would.

Here is the validation rule so far:
"API" & "" & "M" Or "A"

Again, thanks guys!
Your validation rule says that the field value can be "API M" or "A"

Try this:
Left([Field], 4) = "APIM" or Left([Field],4) = "APIA"

Replace [Field] with the name of the field the validation rule applies to.
Jun 21 '07 #2
ADezii
8,834 Recognized Expert Expert
Hello all, and thanks for taking the time to help me out here.

Basically, I am trying to set up a validation rule that correlates with an input mask where the user is required to enter select alpha characters followed by a series of numeric characters.

The input mask Auto-enters API, requires an alpha value in upper case, and up to 8 numeric values., as seen here:

"API"<L99999999

Now, the part I am having trouble with is setting up the validation rule. I need for it to check and make sure that either "M" or "A" have been entered following the auto entered "API". The validation rule (as seen below) will do that, but no matter how much I mess with it I can't seem to get it to allow between 1 and 8 numeric values to be entered following the "M" or "A". Values like APIA1234 (or APIM1234) should be accepted just as APIA12345678 (or API12345678) would.

Here is the validation rule so far:
"API" & "" & "M" Or "A"

Again, thanks guys!
To check if:
  1. The entry begins with API.
  2. The 4th character is either an A or M, nothing else.
  3. There is a minimum of 1 and a maximum of 8 digits following the APIA/M.
  4. All values after the 4th character are Numeric in data type.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub txtTest_BeforeUpdate(Cancel As Integer)
    2. Dim strValueEntered As String, intCounter As Integer
    3.  
    4. strValueEntered = Me![txtTest]
    5.  
    6. If Len(strValueEntered) = 0 Or Left$(strValueEntered, 3) <> "API" Then
    7.   MsgBox "Invalid Entry"
    8.     Cancel = True
    9.     Exit Sub
    10. End If
    11.  
    12. 'Does it pass the A & M test?
    13. Select Case Mid$(strValueEntered, 4, 1)
    14.   Case "A", "M"
    15.   Case Else
    16.     MsgBox "Invalid Entry"
    17.       Cancel = True
    18.       Exit Sub
    19. End Select
    20.  
    21. 'Does it pass the 1 to 8 and Numeric test, namely 1 to 8 digits
    22. 'after the APIM or APIA?
    23. If Len(strValueEntered) >= 5 And Len(strValueEntered) <= 12 Then
    24.   For intCounter = 5 To Len(strValueEntered)
    25.     If Not IsNumeric(Mid$(strValueEntered, intCounter, 1)) Then
    26.       MsgBox "Invalid Entry"
    27.         Cancel = True
    28.         Exit Sub
    29.     End If
    30.   Next
    31. Else
    32.   MsgBox "Invalid Entry"
    33.     Cancel = True
    34.     Exit Sub
    35. End If
    36.  
    37. 'IF YOU EVENTUALLY GET HERE, ALL CONDITIONS WERE MET!
    38. End Sub
Jun 21 '07 #3
bluray
14 New Member
oh wow thanks guys! Both excellent points :) I will test them out right away here and let you guys know how it works out.
Jun 21 '07 #4
ADezii
8,834 Recognized Expert Expert
oh wow thanks guys! Both excellent points :) I will test them out right away here and let you guys know how it works out.
It seems like you will have to go the VBA route on this one. It would be very difficult to incorporate your 4 Validations Requests into a single Validation Rule that would be all encompassing.
Jun 21 '07 #5
bluray
14 New Member
It seems like you will have to go the VBA route on this one. It would be very difficult to incorporate your 4 Validations Requests into a single Validation Rule that would be all encompassing.
I agree. However puppydogbuddy is right about how I botched the original rule I had in mind... can't wait until I reach the Zen level of designing databases you guys are at lol
Jun 22 '07 #6
bluray
14 New Member
ok guys, so I have now implemented the script provided by ADezii and its works great. I only had to tweak a few things to make it fit.

The first thing was of course swapping out the "txttest" control name fillers for the actual names of my controls.

The second thing I had to do was add ;0;_ onto the end of my input mask so it recorded the mask data into the table as well as the user entered data. Otherwise the VB script can't find the "API" portion of the data in the table (because it hasn't been entered and does not exist) and kicks back error messages.

Again thanks all for the help!
Jun 28 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ssmith86 | last post by:
I have created a DAP linking to only one table. Several of the fields on the table have validation rules. The only time my message boxe comes up is when I am finished inputting data on the DAP...
7
by: Tom | last post by:
How do I set up the following Validation Rules in a table: 1. Two chars - both must be digits(0-9) 2. Three characters - first character must be a letter 3. 6 characters - all must be...
5
by: Jeremy | last post by:
I have a vb .net 2003 app that uses access 2k as a backend. The main table has some validation rules (legacy stuff brought forward inadvertantly, and now we're stuck with 'em). The problem is,...
3
by: tsnyder | last post by:
I need to set a validation rule for a field so that it looks at all other fields to make sure that field is true.
7
by: sesling | last post by:
I have a form that has several text boxes where the operator can enter data. I want to place some validation rules around what the operator can enter. In one box I want the number to be at least...
3
by: babamc4 | last post by:
Hi Experts, I have just completed designing a new DB and my boss has asked me to put some complicated (I think!) validation rules on to it. My table is below: 1. Index - Autonumber 2....
7
jinalpatel
by: jinalpatel | last post by:
I have two tables Mainfirm and Subfirm. I have everything ready. Now I am entering validation rules like as below in my form fields to protect the tables from bad data. But when I try to enter...
23
by: Wendy Osullivan | last post by:
I am creating a data base in access 2003 and I was hoping you could help me out with a question I have. In my table I have fields for first name, middle initial, and last name. My primary key...
0
by: Ruth Barn | last post by:
When I use a standard append query; 50 of the 10 'pass', 40 do not append due to validation rules. But the 10 are still not actually added to the TASK table after the append is run and they do not...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.