Prev: Refresh subform
Next: Prevent going to New Record
From: MacNut2004 on 24 Mar 2010 10:39 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
From: Dorian on 24 Mar 2010 11:44 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
From: Daryl S on 24 Mar 2010 12:31 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
From: MacNut2004 on 26 Mar 2010 11:52 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
|
Pages: 1 Prev: Refresh subform Next: Prevent going to New Record |