URGENT: code needed for VBA sub to link 2 textboxes! (1 Viewer)

B

bril_mo

Guest
Can anyone help me out here? These are the things you need to know:

- Box1 and Box2 are two textboxes on Form1.
- When in Box1 a number is typed, a string must appear in Box2.
- The number in Box1 should be a ClientID, the string in Box2 is the CompanyName.
- ClientID and CompanyName are both fields in table Clients.

So the function must read the ClientID in Box1 (OnChange i guess), search Clients for the ClientID, then read the CompanyName in the same record and finally place that string into Box2.

I know there are a lot of experts on this forum, so i expect this thing to be solved today!
 

Chris RR

Registered User.
Local time
Today, 14:35
Joined
Mar 2, 2000
Messages
354
You might want to do this in the after update event for Box 1. You'll need to use the value from Box 1 in a Dlookup statement, which will find the value for Box 2, and then put that into Box 2.

Guess I don't mind answering questions at all, but you have to put a little effort into it, too, so figure out the code yourself.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:35
Joined
Feb 19, 2002
Messages
43,297
The method I perfer is to use an autolookup query. If you're using A97, there's a help entry that tells you exactly how to build the query. Then you use the query as the recordsource for the form. You do have to modify the properties of the fields you "looked up" on the form to prevent updating from this form. Just set their properties to locked. It really doesn't make sense to allow changes to the company name from an order entry form. There's too much risk of an accidental change that would permanantly change the company name for every record associated with that company. It's better to require the user to go to the company maintenance form.
 

Users who are viewing this thread

Top Bottom