Copy info from a combo box to a text box...one form/two tables

  • Thread starter Thread starter Ron S
  • Start date Start date
R

Ron S

Good morning everyone,

I have a form that is based on info in one table. Recently I decided
that I wanted to add a combo box in the same form based on info from
another table. Is there a way once the end user makes there selection
from that combo box that it will copy the selection to a text box on
the same form and clear out the combo box to blank. I know that most
likely will have to be a VBA procedure which is not my strongest area.

Thanks for your help,

Ron
 
Good morning everyone,

I have a form that is based on info in one table. Recently I decided
that I wanted to add a combo box in the same form based on info from
another table. Is there a way once the end user makes there selection
from that combo box that it will copy the selection to a text box on
the same form and clear out the combo box to blank. I know that most
likely will have to be a VBA procedure which is not my strongest area.

Thanks for your help,

Ron

Ron,

I am not sure why you don't want to just have the selected value from
your combo box bound to the value in the form that matches the
selected item, but I will offer a solution since there may be a valid
reason for doing so. In the combo box OnChange event, try the
following code:

If Me.cboItemList.Value <> "" Then ' This code section only fires
if a selection from the drop down list is made
Me.txtInputField.Value = Me.cboItemList.Value ' This sets the
text box value = to the value of the combo selection
Me.cboItemList.Value = "" ' This basically "blanks" the combo
box.
End If

You would need to set the names of the combo box and text field to
your control names, but this should give you the behavior you need.

HTH
- GH
 
I have thought of another approach to this problem. If I use the combo
box wizard and imput the incident types the end user will be using, I
believe this should solve part of the problem. With this app I
imported previous records from another DB, some of the incident types
from back then will not match the ones I will be putting in, I am
figuring the best approach would be to put in a "on not in list"
procedure so there would not be any conflicts when I am viewing
previus records. Does anyone know the code for something like this?

Thanks again,

Ron
 
Ron,

I am not sure why you don't want to just have the selected value from
your combo box bound to the value in the form that matches the
selected item, but I will offer a solution since there may be a valid
reason for doing so. In the combo box OnChange event, try the
following code:

If Me.cboItemList.Value <> "" Then ' This code section only fires
if a selection from the drop down list is made
Me.txtInputField.Value = Me.cboItemList.Value ' This sets the
text box value = to the value of the combo selection
Me.cboItemList.Value = "" ' This basically "blanks" the combo
box.
End If

You would need to set the names of the combo box and text field to
your control names, but this should give you the behavior you need.

HTH
- GH

Thankyou, your code works with the exeption of one small problem which
I think is a settings problems on my end; when I make a selection in
the combo box the result that I am getting is the auto number from
that Incident type.
 
Back
Top