View Full Version : One field updating as a result of another


88AGG
11-09-2001, 04:32 PM
O.K. I feel really stupid asking this after reading all the posts, but I have a very basic problem in the form I'm creating.

I have the following in a table:

SSN Name
111111 John Doe
222222 Betty Boop
333333 Porky Pig
444444 Witchy Poo

I have set up a control box on my form that provides the user a drop down list to chose the social security number and then I would like the "Name" field to update automatically based on the social security number that corresponds.

Right now all I can get is the next name on the list, regardless of what social security number I enter.

Can someone help?

Thanks in advance!

jwindon
11-09-2001, 05:09 PM
Right click on your combo (I will call it combo1, but you need to know its name) and choose the properties. Goto the Data Tab and click the little "build" button next to the ControlSource. You will see a query grid. Put the fields of the SSN FirstName LastName on the grid. So now you have these three. In that order for this example.

Save, yes.

Your name field does not need to be stored as you can refer to that person by a SSN in your relationships. Therefore, the NameFields on the form can be UNBOUND. Change their property on the data tab to be blank. The box will say UNBOUND in design view. (For this example, I will call the Name box - Text1)

Now, right click on the combo1 and choose properties and then the events tab. Find AfterUpdate. Click CodeBuilder and put this code in where it opens.

Me.Text1 = Me.Combo1.Column(1) & " " & Me.Combo1.Column(2)

Let me know if you have trouble.

88AGG
11-09-2001, 07:27 PM
Thanks a lot for the help. I'm going to try it now, and if I have any other questions, I'll post them!

Gig 'em and thanks!