If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Value in Combox populates other fields in form
Hello,
I have a form that has an unbound combobox (Company) that looks up company names in a table. Depending on the value of Company, it will automatically update other fields on the form: Address, Phone Number, State, etc. How do I go about doing this? Thanks! MN |
#2
|
|||
|
|||
Value in Combox populates other fields in form
In After Update event for combo box you insert the code to test for the
selected value and then set the other field values. E.g. Select Case Me!MyCombo Case "Microsoft" Me!SearchEngine = "Bing" Case "Google" Me!SearchEngine = "Google" ... End select If Company selection determines other values it is a sign that you need to control this via a table where you would have the Company and the related values for each other field. It's not good to code such things in your logic. -- Dorian "Give someone a fish and they eat for a day; teach someone to fish and they eat for a lifetime". "MacNut2004" wrote: Hello, I have a form that has an unbound combobox (Company) that looks up company names in a table. Depending on the value of Company, it will automatically update other fields on the form: Address, Phone Number, State, etc. How do I go about doing this? Thanks! MN |
#3
|
|||
|
|||
Value in Combox populates other fields in form
MN -
Set the Row Source for the combo box to pull all the fields you need from the company table. Something like this (but use your table and field names): Select CompanyID, CompanyName, CompanyState, CompanyZip from Company Even though you are pulling 4 (or more) fields from the Company Table, you can choose to only display one of them. You do this with the Column Widths property. This will only show the second column: 0";2.5";0";0" Then in the On Click event for the combo box, add code like this (but use your control names): Me.txtState = Me.cboName.Column(2) Me.txtZip = Me.cboName.Column(3) Note that column(0) refers to the first column in the combobox, etc. -- Daryl S "MacNut2004" wrote: Hello, I have a form that has an unbound combobox (Company) that looks up company names in a table. Depending on the value of Company, it will automatically update other fields on the form: Address, Phone Number, State, etc. How do I go about doing this? Thanks! MN |
#4
|
|||
|
|||
Value in Combox populates other fields in form
Daryl,
Thank you so much - worked like a charm. MN "Daryl S" wrote: MN - Set the Row Source for the combo box to pull all the fields you need from the company table. Something like this (but use your table and field names): Select CompanyID, CompanyName, CompanyState, CompanyZip from Company Even though you are pulling 4 (or more) fields from the Company Table, you can choose to only display one of them. You do this with the Column Widths property. This will only show the second column: 0";2.5";0";0" Then in the On Click event for the combo box, add code like this (but use your control names): Me.txtState = Me.cboName.Column(2) Me.txtZip = Me.cboName.Column(3) Note that column(0) refers to the first column in the combobox, etc. -- Daryl S "MacNut2004" wrote: Hello, I have a form that has an unbound combobox (Company) that looks up company names in a table. Depending on the value of Company, it will automatically update other fields on the form: Address, Phone Number, State, etc. How do I go about doing this? Thanks! MN |
Thread Tools | |
Display Modes | |
|
|