Solved

Best way of Handling Field Level Validations

Posted on 2002-07-23
6
155 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 46

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: 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!

Question has a verified solution.

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

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…
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…
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…
Suggested Courses
Course of the Month6 days, 6 hours left to enroll

627 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