Solved

Best way of Handling Field Level Validations

Posted on 2002-07-23
6
149 Views
Last Modified: 2010-05-02
hi all

I have many forms which requires Only Numeric, Only Alphabetic, BothAlpha Numeric and No spl. characters.

Which is the best suitable approach to validate the form fields before storing it into the database.

Is it possible to write a generalized routine for handling all the forms in common.

do suggestions needed.

thanks
0
Comment
Question by:ayeshanasreen
6 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7172419
For fields to be only numeric of alpha, you better validate on a per-character basis (using the KeyPress event).

For specific field validation (mandatory, minimum length, ...), you better validate in the LostFocus event of each controls.

For referential validation (if FieldA is empty then FieldB must not be empty, ...), you better use form validation (in your save button click event for example).

Using appropriate controls helps you a lot (like a mask edit box, date time picker, ...).
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 100 total points
ID: 7172421
What I had done to handle this is to have a user-control that added a DataType property.  With this, I defined the type of valid data allowed in the field, such as numeric, integer, alpha-only, "sentence", alpha-numeric, e-mail, etc.  When the field is created, define the DataType property and the validation can be done during data entry.

Otherwise, I suppose you'd need some kind of array to define what data is allowed in each field, then check each field against the array information.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 7173384
You can roll-your-own textbox controls or use third-party controls to restrict your users' input.  

My saying to my VB students:
"The best validation is the one that requires no code, because the user is limited to entering only valid data."
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:priya_pbk
ID: 7173475
>>What I had done to handle this is to have a user-control that added a DataType property.  With this, I defined the type of valid data allowed in the field, such as numeric, integer, alpha-only, "sentence", alpha-numeric, e-mail, etc.  When the field is created, define the DataType property and the validation can be done during data entry.<<

If you are interested to create a usercontrol then check out the "PART 2" this link:

http://216.26.168.92/vbworld/file.aspx?tag=activex

It will surely help you to create your own control, without having actually to make validation for each TextBox

-priya

0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7348102
This question appears to be abandoned. A question regarding it will be left in the CleanUp
area; if you have any comment about the question, please leave it here.

Unless there is objection or further activity, one of the moderators will be asked to accept the comment
of <emoreau>.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7373340
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 52
SSRS expression Issue finding a string 10 65
How to debug this code 7 56
VBA filters 2 50
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now