473,793 Members | 2,894 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!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;
Nov 12 '05 #1
6 54324
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!c bxCtlID.Tag

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

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;

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!frmM ain!txtCtlID)

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

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;

Nov 12 '05 #3
then data conversion error was being caused by something else...

"deko" <dj****@hotmail .com> wrote in message
news:dE******** *********@newss vr27.news.prodi gy.com...
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!frmM ain!txtCtlID)

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

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;


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******** ***********@new ssvr27.news.pro digy.com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;

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**********@n ospam-unforgettable.c om> wrote in message
news:dH******** *********@nwrdd c02.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******** ***********@new ssvr27.news.pro digy.com...
Can I reference a column other than the bound column of a ComboBox in a
query?

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;


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.Col umn(x)

Then in your SQL statement use...

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

Hope this makes more sense.

Mike Storr
www.veraccess.com

"Mike Storr" <st******@sympa tico.ca> wrote in message
news:jx******** ************@ne ws20.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!c bxCtlID.Tag

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

SELECT ... WHERE CtlID = Forms!frmMain!c bxCtlID.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!c bxCtlID.Column( 1)

SELECT ... WHERE CtlID = Forms!frmMain!t xtCtlID;


Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2452
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
11509
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
2724
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
1911
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
5527
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 4 4 9/25/06 2 4 4
1
2710
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
5613
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 the rows that pertain to a particular transaction but hold the highest TRANS_SQ value. Below is a...
3
5799
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' to differentiate the two. How would I query the combobox when a radiobutton is selected? Thanks.
2
4999
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 combo boxes (cboProgramme and cboConsultant). I need to store the values from each box in the...
0
9671
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10161
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6777
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.