Auto Fill from selection of combo box

webharvest

New member
Local time
Today, 18:03
Joined
Sep 12, 2006
Messages
6
I set up an Access database to track visiting families. Each person in a family is inserted as a seperate row in my table. The table has the following columns: Visitor # (which is an auto #), Head of household, last name, first name, phone, email, address and etc.

The first person I enter when a family visits is the head of the household. I set up a quiery with a pull down combo box in my form so when I enter a new entry I can select a head of the houshold to assign each person to. Since I put the head of the household in first. I can then select that head of the household (this way I can track each family member seperate but still know they belong to the same family). So if we have a family visit that has a husband, wife and a child. There are three entries each having a head of the household as the same. When I use the query to select the head of the household in the combo box I would like the information that is the same as the original "head of the household" entry (address and phone #) to be automacially filled in from the husband's initial entry.

How can I do this? I read some other post with some VB in them like "Me.TextBox = ComboBox1.Column(3)" but I don't understand the syntax too well since I'm new at this.

Any help would be appreciated.

Thanks
 
In order to achieve what you just descrbied, you need the query
to contain the following fields:

- Head of Household
- Address
- Phone#

In the after update of your combobox, you need to add a sub:

Private Sub ComboboxName_AfterUpdate()
Me.Address = Me.Comboboxname.column(1)
Me.[Phone#] = Me.comboboxname.column(2)
End Sub

The numbers in bracket basically designate the position of your field names
as they appear in your combobox dropdown.

One important thing to remember:

Combo box indexes start with a base of "0";therefore, Head of Household would have an index of "0", Address an index of "1" and Phone# would
be assigned an index of 2.

Hope this helps you.
 
Almost worked

Thanks alot. It almost worked. When I select the head of the household in the combo box it updats the address automatically but not the other information. Here is the code below that I put in the Afterupdate field

Private Sub Head_of_Household_AfterUpdate()
Me.Address = Me.Head_of_Household.Column(1)
Me.City = Me.Head_of_Household.Column(3)
Me.State = Me.Head_of_Household.Column(4)
Me.Zip_Code = Me.Head_of_Household.Column(5)
Me.Assigned_Care_Team = Me.Head_of_Household.Column(7)
Me.Assigned_Care_Team_Member = Me.Head_of_Household.Column(8)
End Sub

Not sure why the others wouldn't update. Any ideas?

Thanks
 
Last edited:
figured it out

I just figured it out. In the combo box properties I had the column count as 2. I should of had it as the number of columns in the query.

It all works now.

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom