×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Text Box validation in a form on OnExit or OnLostFocus

Text Box validation in a form on OnExit or OnLostFocus

Text Box validation in a form on OnExit or OnLostFocus

(OP)
I need to create a macro or a code to check if data entered in the txtCase Text Box of frmContacts exists in a Clients table.
Should I use OnExit or OnLostFocus events?

RE: Text Box validation in a form on OnExit or OnLostFocus

More likely the Before Update event, as you can avoid updating if it's an invalid value. Another common (and easier) way to do this is to use a combo box for that field, with a rowsource of a query/SQL stmt that gets all the unique values for that filed from the Clients table. You can change the text box to a combo on the form itself or (better) in the table design for that filed under Lookup properties.

RE: Text Box validation in a form on OnExit or OnLostFocus

(OP)
First, Elizabeth thanks a lot for your quick response. I am new in the Access field and your help is very much appreciated.
I just realized I was not precise enough when I was writing my questions. I forgot you guys are professionals.
1. The reason I did not use a combo box is that I have more than 13.000 unique case numbers in the Clients table (does it matter?).
2. The Contacts for is rather big and I would like to stop the validation process sooner to save some time for a data entry clerk; that was the reason I was thinking of something else instead the Before Update event.
3.  I do not know any other way how (beside a combo box) to resolve this.











RE: Text Box validation in a form on OnExit or OnLostFocus

I don't have the expertise to advise you about the erformance issues on this. However I can give you more options and you can test them yourself, or you can post another thread in this forum and/or the access:general discussion one with including the word "performance" in it that may attract the attention of someone with more expertise in this area. BTW, these ideas are not mutally exclusive.

Other alternatives:
1)  set up a 1:many relationship with referential integrity. This will not allow you to add a record to the child table that doesn't exist in the parent table.
2) use the DLookup function to look for the client number.
3) use a form with the Clients table as the main source and your child table as the subform. Have the user select the client form the existing table before entering the info.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close