Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 14th, 2012, 11:33 AM
Registered User
 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help

I have been searching for a solution for this issue for two days now.

I have a table with name of people, tblName. I have FirstName and LastName as column. I used a query to combine the first and last name and I use that query for my combo box. I have another table that people can enter the mistakes for their team, tlbErrorLog. The name in tblName is the people who will complete the log or got charge to. They have a unique ID number.

I created a form with unbound controls for them to complete the log. I would like to do is when a name is picked from the combo box, the ID is automatically populated in the text box. This is driving me crazy. Thank you!

James
 
Old October 25th, 2012, 10:59 PM
Authorized User
 
Join Date: Oct 2012
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default Try this!

If i am understanding what you are saying correctly, I did a similar thing a while ago and this is what i did. I created a form for selecting a customer and displaying their details automatically.

On my form I have
customer selection combo box called cboCustomerSelect
unbound text box called customerAddress
unbound text box called customerContact
unbound text box called customerPhone

To make it all work you need the invoke the Row Source Query Builder to list all the fields you want to fill in. Invoke the Row Source query builder for the combo box. In my case, i selected the Customer Company, Customer Address, Customer Contact and Customer Phone fields from my table customerDetails. Close and save the query.

If you view the form and look in the combo box, you will see all four selected fields shown side by side.

In the combo (cboCustomerSelect), build an On Change event.

enter the code:
Code:
Private Sub cboCustomerSelect_Change()
Me.CustomerAddress = Me.cboCustomerSelect.Column(1)
Me.CustomerContact = Me.cboCustomerSelect.Column(2)
Me.CustomerPhone = Me.cboCustomerSelect.Column(3)
End Sub
Me.CustomerAddress - refers to the CustomerAddress text box etc etc

Me.cboCustomerSelect - refers to the customer selection combo box

Column(1) - (confusingly) refers to the second column you see in the combo and so on for the other columns. The column order depends on how you build the row source query.

Hope that helps
__________________
"These pretzels are making me thirsty"









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.