pull up data based on a combo box?

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
How do I create a combo box to pull up data in text boxes or subforms? thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I'll assume that you want to "push" data to textboxes using a selection. IF so, modify the combo's RowSource so that all of the desired data you want to push is in the query. For example, MyCombo is bound to SomeID and you want to push data into Field1, Field2, Field3... The Combo should have the following fields in its query grid (accessed by pressing the ... at the right of the RowSource row):

Code:
SomeID  SomeDescriptiveField Field1 Field2 Field3 etc.

Close, save when prompted, and adjust the ColumnCount (or Columns) property to match the number of fields in the query.

Now go to the Events tab and hit the Builder button in the AfterUpdate event. Select the Code option and you'll be in a module with
Code:
Private Sub MyCombo_AfterUpdate()

End Sub
Your cursor will be in the blank line in the subroutine. Type this:
TextBox1=MyCombo.Column(2)
TextBox2=MyCombo.Column(3)
etc.

The final result is
Code:
Private Sub MyCombo_AfterUpdate()
   TextBox1=MyCombo.Column(2)
   TextBox2=MyCombo.Column(3)
   etc
End Sub

Save, close and give it a go. Note: columns in Combo and ListBoxes are indexed from 0, not 1.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,596
Messages
6,160,716
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