Using a Combobox to Populate a textbox

atrodden

Registered User.
Local time
Today, 17:55
Joined
Jan 23, 2014
Messages
15
This one is really bugging me, I have a table filled with company contacts and form with a combo box containing the contacts names.

When a contact is selected I want it to show their Telephone, Mobile and email address in text boxes below. But it only shows the telephone number and the other two fields stay blank.

Any idea what I'm doing wrong ?

I have this code assigned to the combobox:
Code:
Private Sub MainContact_Change()
Me.Text169 = Me.MainContact.Column(3)
Me.Text167 = Me.MainContact.Column(2)
Me.Text177 = Me.MainContact.Column(1)
End Sub

And this is the row source:
Code:
SELECT tbl_Contacts.Salutation & " " & tbl_Contacts.ContactForename & " " & tbl_Contacts.ContactSurname AS MainContact, tbl_Contacts.ContactTelephone, tbl_Contacts.ContactMobile, tbl_Contacts.ContactEmail
FROM tbl_Contacts
WHERE (((tbl_Contacts.ID_Company)=[tbl_CompanyBookings].[ID_Company]));

Thanks in advance
 
Try your code in the After Update event of the combo box.
 
Have you changed the Column Count of the ComboBox MainContact to 4 so the values are available?

Have you also checked that there is data available in the records you have chosen.
 
Have you changed the Column Count of the ComboBox MainContact to 4 so the values are available?

Have you also checked that there is data available in the records you have chosen.

My Column count was set to 1, changing it to 4 appears to have fixed the problem! Thank you so much! :D
 
You don't even need code. Just set the ControlSources of your text boxes.

ie

=[MainContact]![Column](0)
=[MainContact]![Column](1)
=[MainContact]![Column](2)
 

Users who are viewing this thread

Back
Top Bottom