Create a Combo box that populates 2 fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that I need the user to be able to click a drop down combo box
and choose a person by name; I have two columns showing up for first and last
name. Using the wizard to create the combo box, I'm able to get the Last name
to show up in the location I need it to (on another table in a field called
REALlname) But I can't seem to tie things together so that the REALfname
field is populated by the other column in the combo box.

I looked and see that the control source for my combo box is "REALlname". Is
it possible to have 2 things listed in the control source? Or is there
another way to do this?
 
Thanks for the reply. I did find that page as an answer to someone elses
similar question. I'm using Bound Textboxes, so I use the motheod for Bound
Textbox found at the page. I put the following code in the combo box After
Update Event in the properties of combo box (named Combo30)

Private.Sub combo30_AfterUpdate()
Me.fname.Value = Me.combo30.Column(1)
End Sub

I'm missing something though because when I use the drop down box, I get the
error that the macro doesn't exist.

I don't have a macro for this; I'm not sure what to do from here. I need to
know what kind of macro to create.
 
Not a macro. This is VBA code, and must be put in the form's module.

While in design view of the form, go to the box next to After Update
property for the combo box in Properties window. Delete what you pasted
there. Select from the dropdown [Event Procedure]. Then click on the
three-dot box at right of the dropdown box. Module will open and you'll see

Private.Sub combo30_AfterUpdate()

End Sub

with cursor on blank line in middle. On that line, type the

Me.fname.Value = Me.combo30.Column(1)

code step. Save and close the module.

--

Ken Snell
<MS ACCESS MVP>
 
THANK YOU!!!!!

That absolutely worked and saved me tons of time & frustration!

:)

Andrea ('Mack')

Ken Snell said:
Not a macro. This is VBA code, and must be put in the form's module.

While in design view of the form, go to the box next to After Update
property for the combo box in Properties window. Delete what you pasted
there. Select from the dropdown [Event Procedure]. Then click on the
three-dot box at right of the dropdown box. Module will open and you'll see

Private.Sub combo30_AfterUpdate()

End Sub

with cursor on blank line in middle. On that line, type the

Me.fname.Value = Me.combo30.Column(1)

code step. Save and close the module.

--

Ken Snell
<MS ACCESS MVP>



Mack said:
Thanks for the reply. I did find that page as an answer to someone elses
similar question. I'm using Bound Textboxes, so I use the motheod for Bound
Textbox found at the page. I put the following code in the combo box After
Update Event in the properties of combo box (named Combo30)

Private.Sub combo30_AfterUpdate()
Me.fname.Value = Me.combo30.Column(1)
End Sub

I'm missing something though because when I use the drop down box, I get the
error that the macro doesn't exist.

I don't have a macro for this; I'm not sure what to do from here. I need to
know what kind of macro to create.
 
Back
Top