Multiple column combo box (1 Viewer)

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
When I use a criteria in a query such as [Forms]![FormName]![ComboBoxName] is there a way to use a value from another column other than the first.
For example, I have a combo box that shows the following records: NameID | CityID. Can I use the record of the cityID in the combo box to search records in other combo boxes?

Thank you for your help
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:09
Joined
Oct 29, 2018
Messages
21,534
Hi. Yes, try using the Column() property. It's zero based, so column #1 is Column(0).
 

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
I'm sorry but I'm new to Access and SQL. Can you elaborate how to do that please?
 

June7

AWF VIP
Local time
Today, 11:09
Joined
Mar 9, 2014
Messages
5,492
Query object will not recognize Column() property. If you use an SQL statement in RowSource and comboboxes are all on same form, don't need full path.

SELECT fieldname FROM tablename WHERE somefield = [comboboxname].Column(2);
 
Last edited:

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
I created this thread because I need both the record of the selected NameID and CityID.
About not using Name, it was an example. All my objects are in portuguese, so there's no risk in using reserved words.
 

June7

AWF VIP
Local time
Today, 11:09
Joined
Mar 9, 2014
Messages
5,492
I edited my post after you read it. Review again.
 

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
When I try to use the combo box it says "Undefined function 'Combo33.Column' in expression"
 

June7

AWF VIP
Local time
Today, 11:09
Joined
Mar 9, 2014
Messages
5,492
Post your code. Need column index parameter. Combo33.Column(1)
 

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
SELECT T_Artigo.tamanho, T_Artigo.cor, T_Artigo.nomeID
FROM T_Artigo
WHERE (((T_Artigo.cor)=Combo33.Column(2)) AND ((T_Artigo.nomeID)=[Forms]![Visualizar artigos]![Combo19]));
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:09
Joined
Oct 29, 2018
Messages
21,534
SELECT T_Artigo.tamanho, T_Artigo.cor, T_Artigo.nomeID
FROM T_Artigo
WHERE (((T_Artigo.cor)=Combo33.Column(2)) AND ((T_Artigo.nomeID)=[Forms]![Visualizar artigos]![Combo19]));
Hi. If that doesn't work (because of what @June7 was saying about using the Column() property in queries), then you could just add a hidden textbox on your form and use the Column property there. For example:

=[Comb33].[Column](2)

Then, in your query:

...T_Artigo.cor=Forms!FormName.HiddenTextboxName

Hope that helps...
 

June7

AWF VIP
Local time
Today, 11:09
Joined
Mar 9, 2014
Messages
5,492
Query object would need full path reference but as I said, will not recognize Column() property regardless. If you have SQL statement in combobox RowSource, then it would work.
 

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
I do have. The code I sent is from there
 

Araml

New member
Local time
Today, 20:09
Joined
May 4, 2020
Messages
22
Hi. If that doesn't work (because of what @June7 was saying about using the Column() property in queries), then you could just add a hidden textbox on your form and use the Column property there. For example:

=[Comb33].[Column](2)

Then, in your query:

...T_Artigo.cor=Forms!FormName.HiddenTextboxName

Hope that helps...

I can never make my text boxes function properly.
I tried a combo box after update event where Me.TextBox = Me.ComboBox.Column but it didn't work
 

theDBguy

I’m here to help
Staff member
Local time
Today, 12:09
Joined
Oct 29, 2018
Messages
21,534
I can never make my text boxes function properly.
I tried a combo box after update event where Me.TextBox = Me.ComboBox.Column but it didn't work
Hi. No need to use code. In the hidden textbox, simply type in the following (including the equas sign):

=[ComboboxName].[Column](2)
 

June7

AWF VIP
Local time
Today, 11:09
Joined
Mar 9, 2014
Messages
5,492
All I can say is it works for me. If you want to provide db for analysis, follow instructions at bottom of my post.
 

Users who are viewing this thread

Top Bottom