473,517 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 54293
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
2430
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 aproximation of what they were: Query #1: --------- SELECT 12 AS ,
5
11488
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 { CarsSoldID int (primary key) MonthID int DealershipID int NumberCarsSold int
2
2707
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 work when Grant is null. What's the proper syntax for getting it to work when Grant is null? Here's my Where criteria: !!
1
1897
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 background when the form opens, so that when I click the dropdown, it is ready. How?
3
5522
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 Action1 Action2 Action3 9/1/06 2 4 4 9/8/06 2 4 4 9/15/06 2...
1
2691
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
5601
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 (transaction data that is). The trasactions can be later modified and this causes for the field TRANS_SQ to auto increment. What I want to do is query for...
3
5771
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 the states and vice versa for country. I've create two columns in the Origin table (OriginState and OriginCountry) and set the data type to 'bit'...
2
4986
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 programme of work for a client. I have created a form (frmEnterExpenses) to enter expenses against a programme for each consultant. The form has two...
0
7297
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7432
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7600
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7557
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5123
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4787
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3278
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1643
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.