Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to create a Data entry field that validates

Status
Not open for further replies.

KaayJaay

IS-IT--Management
Jul 6, 2004
64
US
I would like to have a data validating entry field that will basically force the user to enter valid information into the pop up text box. As opposed to allowing the user to enter garbage and then in turn spitting out garbage. Any Suggestions?

KaayJaay
 
1. Input masks.
2. Can you limit the user's choices? i.e., if there are only a limited amount of things a user can put it, I usually place them in a table, and then put a combo box on the form that gets populated by linking back to the choices in that table. Then the user can only input the choices in the combo box, and the form will not accept anything but what populates that combo box.

does that make sense?

I am a nobody, and nobody is perfect; therefore, I am perfect.
 
Take a look at the BeforeUpdate event procedure and its Cancel capability.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
KaayJaay

Data validation is a "huge" and open-ended topic.

Here are some things to consider...

Design Level
- Your database design schema will help ensure data integrity. For example, enforcing referential integrity for Invoice / Invoice detail records will prevent "orphans".
- Use correct data types, and reasonable limits. For example, when defining a field called FirstName, do you need a max of 50 characters. Likewise, you can set input masks.
- You can use unique indexes to prevent duplicate entries. But be careful with over use of indexes -- they create overhead.

Form Level
- Use the form and field properties window to set masks and default values.
- You can use code with AfterUpdate field event procedure to verify specifics
- Verify related data exists with functions such as DLookUp.
- You can use BeforeUpdate record event procedure to check all data before updating or inserting a new record for integrity.

User Friendly interface
Providing a simply, intuitive user interface will also help avoid data issues. For example, by using combo or list boxes, and search capabilties within a data entry form will minimize data entry errors. For example, for a regional contact database, you could use a combo box for the Street name. The end user starts typing in the name of the street, and the combo box fills in the rest entry for the user - this saves time, and minimizes typing mistakes.

For more info, use the Tek-Tips search feature, key word validation or related words. Here is a starter link...

Richard
 
Thank You, But in using the after update, doesnt the data get processed before the After Update is run? I want to be able to say to the user, invalid entry, without having garbage data sent.

KaayJaay
 
Consider scope...

You have event procedures that apply to the entire form. commonly used event procedures for the form are
- OnCurrent record
- BeforeUpdate record (validate here)
- AfterUpdate record
- OnDirty
- OnDelete
- OnLoad / Unload

You also have event procedures that apply to the fields on the form. Typical ones used are...
- AfterUpdate feild (validate here)
- OnDirty (can validate here too)
- OnClick / DoubleClick
- OnFocus
- NotInList

At the field level, you can cancel / reverse the entry, set the "focus".

For example, OnDirty is a property that is set to store the old value if a new value is entered. If the field entry is invalid, you can cancel which then restores the dirty / old value to the field. You would typically do this action using the AfterUpdate field event procedure.
 
Agree with both PHV Willir

PHV for the short term, immediate problem,
and
Willir for the big picture.

I would try the beforeUpdate event with the cancel capability



I am a nobody, and nobody is perfect; therefore, I am perfect.
 
Hey is there a way to popping up a Alarm message or prompt, instead of an Message box? My reason for asking is, i dont know visual basic code, but i want to use a before update that will check to see if such a record exist in my database, and if it does, than continue to display record, if it doesnt, than pop-up an alert saying there is no record. Instead of pulling up a blank report if invalid data is entered.

KaayJaay
 
KaayJaay

Beyond the design level and form properties, you pretty well have to get your fingers dirty with VBA or macros.

However, some of the basic stuff is actually quite easy -- the biggest leap is to get your toes wet with some simple coding. Once you gain confidence with some simple stuff, you will see "how" it works, and can move on.

Post details on one field on one form that you need help with, and "we" will see what we can do. What is the purpose of the form, purpose of field, name of field...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top