By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,828 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

How to reference ComboBox Column(1) in query?

P: n/a
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not
seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;
Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If you are trying to do this from a QueryDef object (Queries Tab) then you
can only get at the value (bound column) of the control.
If you are not using the Tag property of the combobox, you could assign the
needed column to it, instead of creating another control.
example: SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Tag

Mike Storr
www.veraccess.com
"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not
seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;

Nov 12 '05 #2

P: n/a
I tried the hidden textbox workaround (which works), but I need to convert
the number in Me!txtCtlID to Long data type in an Update query:

UPDATE tblProperties SET NewCtlID = CLng(Forms!frmMain!txtCtlID)

but this fails due to data type conversion error...
"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not
seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;

Nov 12 '05 #3

P: n/a
then data conversion error was being caused by something else...

"deko" <dj****@hotmail.com> wrote in message
news:dE*****************@newssvr27.news.prodigy.co m...
I tried the hidden textbox workaround (which works), but I need to convert
the number in Me!txtCtlID to Long data type in an Update query:

UPDATE tblProperties SET NewCtlID = CLng(Forms!frmMain!txtCtlID)

but this fails due to data type conversion error...
"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;


Nov 12 '05 #4

P: n/a
Why is your ID field in Column 1 of the combo. Shouldn't it be in column 0?
"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not
seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;

Nov 12 '05 #5

P: n/a
It really doesn't matter which column you use as the bound one, it just
depends on what you are doing with that value.

Mike Storr
www.veraccess.com
"Robert" <ro**********@nospam-unforgettable.com> wrote in message
news:dH*****************@nwrddc02.gnilink.net...
Why is your ID field in Column 1 of the combo. Shouldn't it be in column 0?

"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;


Nov 12 '05 #6

P: n/a
Sorry I should have included the step of assigning the value to the tag
property first. In the combobox AfterUpdate event, add this..

'x is the column you wish to retrive.
Me!cbxCtlID.Tag = Me!cbxCtlID.Column(x)

Then in your SQL statement use...

SELECT .<add fields to retrive>.. WHERE CtlID = Forms!frmMain!cbxCtlID.Tag;

Hope this makes more sense.

Mike Storr
www.veraccess.com

"Mike Storr" <st******@sympatico.ca> wrote in message
news:jx********************@news20.bellglobal.com. ..
If you are trying to do this from a QueryDef object (Queries Tab) then you
can only get at the value (bound column) of the control.
If you are not using the Tag property of the combobox, you could assign the needed column to it, instead of creating another control.
example: SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Tag

Mike Storr
www.veraccess.com
"deko" <dj****@hotmail.com> wrote in message
news:ng*******************@newssvr27.news.prodigy. com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!cbxCtlID.Column(1); (this does not seem to work)

Or must I add a hidden text box on frmMain and use this:

Me.txtCtlID = Forms!frmMain!cbxCtlID.Column(1)

SELECT ... WHERE CtlID = Forms!frmMain!txtCtlID;


Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.