473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Validation Rule for combined Text & Number

Hi,

I need to accept in my Textbox ONLY 5 Alphaphetic 4 numeric and 1 Alphaperic. So, Totally 10 characters only should accept. And there should not be any space..

How can i Set validation rule & show my own message for this...?

Any suggestion would be appreciated GREATLY.

Thanks in advance.

ngr.
Jun 9 '07 #1
6 3188
ADezii
8,834 Expert 8TB
Hi,

I need to accept in my Textbox ONLY 5 Alphaphetic 4 numeric and 1 Alphaperic. So, Totally 10 characters only should accept. And there should not be any space..

How can i Set validation rule & show my own message for this...?

Any suggestion would be appreciated GREATLY.

Thanks in advance.

ngr.
Instead of a Validation Rule why not create an Input Mask? The following Input Mask will allow only 5 Alphas - 4 Numerics - 1 Alpha (no spaces):
LLLLL0000L
Jun 9 '07 #2
Instead of a Validation Rule why not create an Input Mask? The following Input Mask will allow only 5 Alphas - 4 Numerics - 1 Alpha (no spaces):
LLLLL0000L
============
Thnx...

Fine..But, I tried to show my own message instead of Access message in the message box as below ...But, its not working...

If Not IsNull([Vendor_TAN_No]) Then
If Vendor_TAN_No.InputMask <> "LLLLL0000L" Then
MsgBox "Eh..! The TAN Number must be 5 Alphapetic,4 Numeric, 1 Alphaphetic. Example : ABCDE1234A", vbOKOnly, "Vendor Creation"
Screen.PreviousControl.SetFocus
End If
End If

Can anybody suggest to me ....?

Your suggestion would be appreciated greatly.

Thanks in advance.

ngr.
Jun 14 '07 #3
ADezii
8,834 Expert 8TB
============
Thnx...

Fine..But, I tried to show my own message instead of Access message in the message box as below ...But, its not working...

If Not IsNull([Vendor_TAN_No]) Then
If Vendor_TAN_No.InputMask <> "LLLLL0000L" Then
MsgBox "Eh..! The TAN Number must be 5 Alphapetic,4 Numeric, 1 Alphaphetic. Example : ABCDE1234A", vbOKOnly, "Vendor Creation"
Screen.PreviousControl.SetFocus
End If
End If

Can anybody suggest to me ....?
If Me!Vendor_TAN_No.InputMask <> "LLLLL0000L" Then


Your suggestion would be appreciated greatly.

Thanks in advance.

ngr.
Where exactly is the location of this code?
Jun 14 '07 #4
Where exactly is the location of this code?
-----
Its located in next controls of the gotfocus event..

Even, i tried with After_update of current control as below

If Not IsNull([Vendor_TAN_No]) Then
If Vendor_TAN_No.InputMask <> "LLLLL0000L" Then
MsgBox "Eh..! The TAN Number must be 5 Alphapetic,4 Numeric, 1 Alphaphetic. Example : ABCDE1234A", vbOKOnly, "Vendor Creation"
me!Vendor_TAN_No = null
Screen.PreviousControl.SetFocus
Endif

Your suggestion would be appreciated greatly.

Thanks in advance.

ngr.
Jun 15 '07 #5
If you want to alert the user before updating the control, place the code in the BeforeUpdate event...


-----
Its located in next controls of the gotfocus event..

Even, i tried with After_update of current control as below

If Not IsNull([Vendor_TAN_No]) Then
If Vendor_TAN_No.InputMask <> "LLLLL0000L" Then
MsgBox "Eh..! The TAN Number must be 5 Alphapetic,4 Numeric, 1 Alphaphetic. Example : ABCDE1234A", vbOKOnly, "Vendor Creation"
me!Vendor_TAN_No = null
Screen.PreviousControl.SetFocus
Endif

Your suggestion would be appreciated greatly.

Thanks in advance.

ngr.
Jun 23 '07 #6
ADezii
8,834 Expert 8TB
Hi,

I need to accept in my Textbox ONLY 5 Alphaphetic 4 numeric and 1 Alphaperic. So, Totally 10 characters only should accept. And there should not be any space..

How can i Set validation rule & show my own message for this...?

Any suggestion would be appreciated GREATLY.

Thanks in advance.

ngr.
You must Trap the specifc Validation Error in the Form's Error() Event, display your own Custom Error Message, and tell Access not to display its own Error Message as in:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Error(DataErr As Integer, Response As Integer)
  2. Const conValidationRuleViolation = 2279
  3. Dim Msg As String
  4. Msg = "Eh..! The TAN Number must be 5 Alphapetic,4 Numeric, 1 Alphaphetic. Example : ABCDE1234A"
  5.  
  6. Select Case DataErr
  7.   Case conValidationRuleViolation
  8.     MsgBox Msg, vbOKOnly, "Vendor Creation"
  9.     Response = acDataErrContinue
  10.   Case Else
  11.     MsgBox Err.Description, vbExclamation, "Error in Form"
  12. End Select
  13. End Sub
Jun 23 '07 #7

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

Similar topics

2
by: Joey P | last post by:
Hi all, I am doing a project for university whereby i have to implement a simple database related to a frozen foods company. I am having some trouble though creating a validation rule for one...
0
by: Steve V | last post by:
I'm using Access 2000 to build a budgeting/tracking database. Can I make a validation rule (using VBA) that checks the data as if the record has already been added? I've got 5 tables (only the...
0
by: Boulent Mustafa | last post by:
Using Microsoft Access 2000, I am defining a bunch of fields all with default values. The reason for this is that I have 5 text fields, each of which can have 5 permutations depending on the...
3
by: GGerard | last post by:
Hello In a text box, I would like the user to be able to enter only a number from 0 to 100 (including decimals Ex: 24.56) so I wrote this in the Validation Rule Propertie of the text box : >=...
6
by: Chuck | last post by:
A97. A database has a table: tblA which has a single text field, B. It is a primary field, indexed and no duplicates. It is used as a lookup for table tblC. A form based on tblA is used to add...
6
by: Michael R | last post by:
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule. My input mask for this field is: \000\-0000000;;...
2
by: voroojak | last post by:
Hi i just want the user can enter number not any thing else in form. i tried >like "*#*"< in validation validation rule area and it seems that it is working and put just >accept number< in...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
2
by: slenish | last post by:
Hello all, Im having some problems creating a validation rule with VBA. What I have is a form with a text box. When you start to type in the text box I want to have a validation rule set so you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...

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.