Solved

Best way of Handling Field Level Validations

Posted on 2002-07-23
6
148 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now