Combo Box to Look Up Record

Parra

Well-known Member
Joined
Feb 21, 2002
Messages
752
I know how to create combo boxes.

What I would like to do is to use a combo box on a form, and when I choose an item from it, pull its related data to the form.

How could I do this.

Parra
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I'm guessing that you're wanting to be populating a text box. The first thing that you would do is to create your combo box and text box. Then, after you make a combo selection, the text box is populated. You can do this with some pretty simple VBA:

Code:
Your_Combo_AfterUpdate()
Me.Your_Textbox=Me.Your_Combo
End Sub
 
Upvote 0
:oops: Dugantrain, we have been working on this via email, and I got the code to work, BUT it's returning with the same info on the COMBO box... I want to get the description of a given part number in the combo box, this info is already stored in the same table as the part number... could somebody help me?
 
Upvote 0
So what you're saying is that in a given record you have two fields: part number, part description. You want the combo to display only the part number, but you want the text box to populate with part description. If this is correct:

-Go to the Combo's Properties
-Go to Data-> Row Source
-This will pull up a Query Builder for the Combo Box. Pull in both fields.
-Close the Query Builder. In the Combo's Properties, go to Column Count. Type in '2'.
-Now go to Column Width. Type in 1.5'';0'' or however wide you'd like your visible column; the important thing is to have the column that you want to be invisible to have a Width of 0''.
-You'll now need to alter the VBA code so that the text box populates with the correct field:
Code:
Your_Combo_AfterUpdate() 
Me.Your_Textbox=Me.Your_Combo.Column(1)
End Sub
Column Counts always start with a Value of 0, so in my example above, Column(1) would actually be the Second column.

In case you're wondering, yes it's close to XMas and no I don't have a damned thing to do at work.
 
Upvote 0
(y) THAT DID IT!!!! I owe you a Beer...or 2
thx Man!!!

Parra, I have it working now....

Everybody else..... this works! this is one of the most common things you want to have in your database... it helps alot when you are doing data entry..
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,711
Members
451,665
Latest member
PierreF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top