Solved

Best way of Handling Field Level Validations

Posted on 2002-07-23
6
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 70

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 70

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 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