473,406 Members | 2,467 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,406 software developers and data experts.

Tips on field validation

I am trying to validate the fields in my database.I have already
validated the fields to check for not null.Here is what I have written
for Numeric and text field.
Private Function EENUM()
On Error GoTo EENUMErr

If IsNull(Me.EmployeesID) Or Me.EmployeesID = "" Or Me.EmployeesID
< 0 Then
MsgBox "Employee Number Cannot Be Left Blank", vbOKOnly,
"Employee Number"
EmployeesID.SetFocus
End If

EENUMErr:
If Err <> 0 Then
MsgBox "Error #: " & Err.Number & " Description: " &
Err.Description, , "Employee ID Error!"
Exit Function
End If

End Function (This checks for nulls values in the employee number
field)

I want to add a message if a text field is entered in this field And I
want to put up a message if the user enters more than 4 digits.I have
already set the field length to 4 at the design time

And I have written the following for the text field.
Private Function EFN()
On Error GoTo EFNErr

If IsNull(Me.FirstName) Or Me.FirstName = "" Then
MsgBox "Enter Employees First Name", vbOKOnly, "First Name"
FirstName.SetFocus
End If

EFNErr:
MsgBox "Error #: " & Err.Number & " Description " & Err.Description, ,
"First Name Error!"
Exit Function
End Function

This checks for nulls in the Employye field and I want to add a
message if user enters anything other than text.

Can anyone help me with this?

Thanks
Nov 12 '05 #1
2 10396
See MSKB 208949 for an example of field validation:
Flexible Input Mask for Entering Five- or Nine-Digit ZIP Codes
http://support.microsoft.com/default...b;en-us;208949

You can set a validation rule property for the allowed length, as shown in step 3 of the
above article. As an alternative, you can set this validation rule at the field level in
table design view, and include the appropriate validation text if the data entry does not
follow this rule.

Some other useful articles include MSKB 210385:
Validation Rule to Accept Only Alphabetical Characters
http://support.microsoft.com/default...b;en-us;210385

and MSKB 209049
Input Mask Character (!) Does Not Work as Expected
http://support.microsoft.com/default...b;en-us;209049

For example, a validation rule of Like "####" should limit the data entry to (4)
numeric digits.

Tom
____________________________________________

"Doslil" <do****@hotmail.com> wrote in message
news:c6*************************@posting.google.co m...

I am trying to validate the fields in my database.I have already
validated the fields to check for not null.Here is what I have written
for Numeric and text field.
Private Function EENUM()
On Error GoTo EENUMErr

If IsNull(Me.EmployeesID) Or Me.EmployeesID = "" Or Me.EmployeesID
< 0 Then
MsgBox "Employee Number Cannot Be Left Blank", vbOKOnly,
"Employee Number"
EmployeesID.SetFocus
End If

EENUMErr:
If Err <> 0 Then
MsgBox "Error #: " & Err.Number & " Description: " &
Err.Description, , "Employee ID Error!"
Exit Function
End If

End Function (This checks for nulls values in the employee number
field)

I want to add a message if a text field is entered in this field And I
want to put up a message if the user enters more than 4 digits.I have
already set the field length to 4 at the design time

And I have written the following for the text field.
Private Function EFN()
On Error GoTo EFNErr

If IsNull(Me.FirstName) Or Me.FirstName = "" Then
MsgBox "Enter Employees First Name", vbOKOnly, "First Name"
FirstName.SetFocus
End If

EFNErr:
MsgBox "Error #: " & Err.Number & " Description " & Err.Description, ,
"First Name Error!"
Exit Function
End Function

This checks for nulls in the Employye field and I want to add a
message if user enters anything other than text.

Can anyone help me with this?

Thanks
Nov 12 '05 #2
TC
I said to you in an earlier thread:

You should put checking code like this in the BeforeUpdate event - not in a
private function.. If an error occurs, set the Cancel parameter of that
event to True. That will stop the focus from leaving the control. Discard
the SetFocus statement.

But you are naturally free to ignore that advice! :-)

TC
"Doslil" <do****@hotmail.com> wrote in message
news:c6*************************@posting.google.co m...
I am trying to validate the fields in my database.I have already
validated the fields to check for not null.Here is what I have written
for Numeric and text field.
Private Function EENUM()
On Error GoTo EENUMErr

If IsNull(Me.EmployeesID) Or Me.EmployeesID = "" Or Me.EmployeesID
< 0 Then
MsgBox "Employee Number Cannot Be Left Blank", vbOKOnly,
"Employee Number"
EmployeesID.SetFocus
End If

EENUMErr:
If Err <> 0 Then
MsgBox "Error #: " & Err.Number & " Description: " &
Err.Description, , "Employee ID Error!"
Exit Function
End If

End Function (This checks for nulls values in the employee number
field)

I want to add a message if a text field is entered in this field And I
want to put up a message if the user enters more than 4 digits.I have
already set the field length to 4 at the design time

And I have written the following for the text field.
Private Function EFN()
On Error GoTo EFNErr

If IsNull(Me.FirstName) Or Me.FirstName = "" Then
MsgBox "Enter Employees First Name", vbOKOnly, "First Name"
FirstName.SetFocus
End If

EFNErr:
MsgBox "Error #: " & Err.Number & " Description " & Err.Description, ,
"First Name Error!"
Exit Function
End Function

This checks for nulls in the Employye field and I want to add a
message if user enters anything other than text.

Can anyone help me with this?

Thanks

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shabam | last post by:
I know that dotnet allows for form field validation. However I'm looking to customize the error message display and am wondering if it's possible to do what I need. Example: Suppose in a...
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...
3
by: Rick | last post by:
I have an interesting problem when I run the following code in Netscape (7.02) vs. IE. This page works great in IE and all my controls bring up the validation summary dialog box if the required...
6
by: Paul | last post by:
I am trying to setup a field validator and tried using the control to validate set to a dropdown list box but did not seem to work. Is there anyway to set this up or do you need to use client side...
3
by: Kivak Wolf | last post by:
Hi, Could someone give me a quick review of how to use the required field Validator? I'm completely at a loss, and MSDN does not help one bit. =/ Basically all I want done is to make sure that...
1
by: Niclas | last post by:
Hi, How do I indicate what field fails a validation, usually you see a red star next to the faild field on a form. Is this built in functionality in the valdaition controls or shall I code this...
1
by: AECL_DEV | last post by:
Hello Everyone, Ive seen alot of people saying that the best way to AJAX Validate a form is through the submit button, because validation should be synchronous. Im wondering, is there any good...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.