Changing combo box's boundcolumn in VBA to get multiple values from a combo. (1 Viewer)

TheVisionary

New member
Local time
Today, 13:36
Joined
May 11, 2008
Messages
2
Hello everyone,

I have come across a strong coding problem for something which should be a relatively simple task.

Basically, I’m wanting to store both values found in the columns of a combo box into different list box's. The combo box has the bound column to the key column in a query and the other is the name.

For administration later, the keys will be entered into an invisible table while the user will see exactly what they have selected in their visible list box, then all relative values for selecting records can be used.

Anyway, onto the problem, I thought if i changed the bound column then i could just save both values. Problem is, access 2003 still only stores the key values in both tables.

Here is my code:
Dim list As String

list = Me.cboManufacturer & ";" & Me.cbocategory & ";" & Me.cboProdID & ";" & Me.txtQuantity

Me.lstData.AddItem (list)

Me.cboManufacturer.BoundColumn = 1
Me.cbocategory.BoundColumn = 2
Me.cboProdID.BoundColumn = 2

Me.cboManufacturer.Requery
Me.cbocategory.Requery
Me.cboProdID.Requery

list = Me.cboManufacturer & ";" & Me.cbocategory & ";" & Me.cboProdID & ";" & Me.txtQuantity

Me.lstproduct.AddItem (list)

Me.cboManufacturer.BoundColumn = 2
Me.cbocategory.BoundColumn = 1
Me.cboProdID.BoundColumn = 1

Me.cboManufacturer.Requery
Me.ccbocategory.Requery
Me.cboProdID.Requery

Any help would be much appreciated. I tried putting requery scripts in for both the combos and the form with no affect.

Thank you,
TheVisionary

N.B. To add into perspective what the aim of the form is to do. The user selects a manufacturer, category and product identifier from combos as well as entering a quantity. Only when the user has entered these entire can they issue it to be entered into the list box. The user can then see a summery in the list box of all stock which is being entered into the system before proceeding.
 
You don't need to change the bound column. All you need to do is use the column property:

Me.WhateverControl = Me.YourComboBoxName.Column(x)

Where x is the column number - zero based - so if you want column 2 you put Column(1)
 
Great stuff. Thought it was somthing like that in the beginning but couldnt get access to prompt me when i did open bracket and thought that it has no operators.

Many thanks for your help.
 
GladWeCouldHelp.png
 

Users who are viewing this thread

Back
Top Bottom