473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

I want a Combo Box to display 2 Columns and populate 2 controls

I need a combo box with 2 columns to assist in record the proper record.

But after combo box selection -

I want the first column to remain in the combo box.

And second column to populate another control on the form.

Thank you in advance for your help!!
Sep 2 '15 #1

✓ answered by jforbes

How to do this depends on if the control to populate (Destination Field) is Bound or Unbound.

If it is Bound, then put some code like this in the AfterUpdate Event for the ComboBox control:
Expand|Select|Wrap|Line Numbers
  1. Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & me.ComboBox.Value & "")
  2. or 
  3. Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & Me!FieldSelectedinComboBox & "")
If the Destination Field is Unbound, the easiest way I've found it so put the DLookup into the Control Source property of the Destination.
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & [FieldSelectedinComboBox] & "")[/
then you'll need to add a Requery for the Destination Field in the Combobox's AfterUpdate event and the FormCurrent Event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSourceComboBox_AfterUpdate()
  2.     Me.txtDestinationField.Requery
  3. End Sub
  4. Private Sub Form_Current()
  5.     Me.txtDestinationField.Requery
  6. End Sub

2 1114
jforbes
1,107 Expert 1GB
How to do this depends on if the control to populate (Destination Field) is Bound or Unbound.

If it is Bound, then put some code like this in the AfterUpdate Event for the ComboBox control:
Expand|Select|Wrap|Line Numbers
  1. Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & me.ComboBox.Value & "")
  2. or 
  3. Me!FieldTheBoundColumnIsBoundTo=DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & Me!FieldSelectedinComboBox & "")
If the Destination Field is Unbound, the easiest way I've found it so put the DLookup into the Control Source property of the Destination.
Expand|Select|Wrap|Line Numbers
  1. =DLookUp("FieldToLookup","TableFromComboBox","FieldSelectedinComboBox=" & [FieldSelectedinComboBox] & "")[/
then you'll need to add a Requery for the Destination Field in the Combobox's AfterUpdate event and the FormCurrent Event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSourceComboBox_AfterUpdate()
  2.     Me.txtDestinationField.Requery
  3. End Sub
  4. Private Sub Form_Current()
  5.     Me.txtDestinationField.Requery
  6. End Sub
Sep 2 '15 #2
Sorry that I have not reply to you early. I have not had a opportunity to try your suggestion. But I would like to thank you for your help. And I will keep you posted as implement your suggestion.
Thank you, again.
Sep 8 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: mikel | last post by:
Hello, I have several characters in my html code like / W and so on.... The problem is, tehy are converted in HTML in their approbiate characters like @ is @ and F is F But I DONT want to...
3
by: Ken | last post by:
I have a database called autographs.mdb that is in the "XYZ" folder in the "database" folder. I have a form in the database that I want to display a photo of the celeb on. The photos are in a...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
1
by: indhu | last post by:
Hi all, I want 2 know, how to populate using 2 combo box to populate other field. right now am using click event of combo to populate the other field but i want to select both combo1 and combo2 ...
3
by: sheenaa | last post by:
Hello friends, I m using ASP.NET with C# 2005 and SQL SERVER 2005 for the ASP.Net Website. I m using sqldatasource to connect and retrieve the data from database and then it displays the data...
1
by: rinku123 | last post by:
hi dear i want to Display report in Msword (.doc) can it possible. in vb6 i display some info in form using label controls. when i press report button it show in ms word file. if possible then...
1
by: monikagovindaraj | last post by:
hello sir, i want to create three columns on my table. the third column, i want to display each button has unique color. after am click that button it will be displayed the overall color...
0
by: Tony K | last post by:
I made a grid with several columns. 2 of the columns are foreign keys from 2 other tables in the datasource. I am unable to sort alphabetically by the combo box columns when I click on the column...
2
by: chinni1 | last post by:
Hii.. Im retreving the data from database using table1.so im taking the values in array. so using loop im displaying the values in single line .like one two three four five ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.