Updating Mutilple Fields with a Single Combo box

  • Thread starter Thread starter Bobbak
  • Start date Start date
B

Bobbak

Hello All,
I was wondering if it is at all possible to have a single combo box
update multiple fields in a single record. For example I have created
an Employee Info form, and in that form there's a combo box (called
"DirectorName") that contains the Directors Info that is connected to
a table called "tblDirector" that has the Director's First Name, Last
Name, and Director ID. Now all three fields appear in the one combo
box (which the user wants), when the user click a button to save the
changes I want it to take the content selected in the "DirectorName"
combo box and have it update the exact same field names in the
"EmployeeInfo" table. If anyone can let me know how I can go about
doing this, or if it is at all possible, I'd very like to know how.
 
Assuming those fields are also on your employee form, you
can add code to the AfterUpdate event of your DirectorName
combo box similar to this:

Me.DirectorFirstName.Value = Me!DirectorName.Column(0)
Me.DirectorLastName.Value = Me!DirectorName.Column(1)
Me.DirectorID.Value = Me!DirectorName.Column(2)

The column property is zero-based so your first column =
0, second = 1, etc. These relate to the columns you are
pulling into the DirectorName combo box.

Hope that helps.
 
You can use the combo box Column property to access it's column data. For example, [ComboBoxName].Column(0) would return the
first column in the currently selected row of combo box [ComboBoxName]. [ComboBoxName].Column(1) would return the second
column on the currently selected row, which you could assign a field to equal this value. You can specify 2 numbers for this
property, which the second number would then be the row index to return a column that is not the currently selected row, but
this defaults to the ListIndex value so that it will be selecting from the current row if you don't specify.

FieldA = [ComboBoxName].Column(1)
FieldB = [ComboBoxName].Column(2)

More information on the Column property can be found in the help files.

Hello All,
I was wondering if it is at all possible to have a single combo box
update multiple fields in a single record. For example I have created
an Employee Info form, and in that form there's a combo box (called
"DirectorName") that contains the Directors Info that is connected to
a table called "tblDirector" that has the Director's First Name, Last
Name, and Director ID. Now all three fields appear in the one combo
box (which the user wants), when the user click a button to save the
changes I want it to take the content selected in the "DirectorName"
combo box and have it update the exact same field names in the
"EmployeeInfo" table. If anyone can let me know how I can go about
doing this, or if it is at all possible, I'd very like to know how.

Jeremiah Ellison
Ellison Enterprises - Your One Stop IT Experts
 
Back
Top