473,387 Members | 1,510 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,387 software developers and data experts.

How to reference ComboBox Column(1) in query?

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
6 54275
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Thomas R. Hummel | last post by:
Hi, I was just helping a coworker optimize a query. He had two versions: one which used UNION for each value for which he was tallying results and another query which used GROUP BY. Here is an...
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
2
by: Ellen Manning | last post by:
Using A2K. In my table I have the field "Grant" which can have a value or be null. I have a query that counts the number of records and has a Where clause on the Grant field. The query won't...
1
by: Jean | last post by:
Hi, I think this is quite a simple one: I have a ComboBox, where the source is a stored query. When I click the drop-down arrow on the Box, it takes awhile. I want to run this query in the...
3
by: prime80 | last post by:
I have a database report that is based on a query that returns actions taken on certain dates. The data looks like this: (The report based on this query is layed out similarly) Date ...
1
by: Oliver Bleckmann | last post by:
Damn, what's wrong here? CGI cgi; map<string,stringcgiParam = cgi.analyseCgiParam(); cout << cgiParam << endl; cout << cgiParam << endl; /////////////////////// #include <iostream>
1
by: oval | last post by:
This is probably a general SQL question but since I am dealing w/ DB2 I figured I would ask here. I have a table with customer transaction information. The primary keys are cust_id and date...
3
by: Eric | last post by:
Hi. I have this Combobox name 'Origin' that contains all states and countries. I would like to create two Radio buttons (State and Country) that when you select State, the combobox will query only...
2
by: 20028431 | last post by:
Hi Guys looking for some help please. Is a bit complex but will try to keep explination as succint as possible - here goes - I have a Access 2007 database allocating consultants against a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.