473,503 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Value from a comboBox as text

25 New Member
Hey All;

I have a form with a ComboBox. I populate the ComboBox with the following query:

Expand|Select|Wrap|Line Numbers
  1. SELECT [customers].[id], [customers].[name] FROM customers ORDER BY [customers].[name]; 
This query populates the comboBox with all the customer names from the customer table. I want to be able to select a customer from the comboBox and pass it as a parameter to another query, but what I keep getting is the customers.id from the customers table as an integer when I really want the customers name as text or a string. The other query use the table called "receipts" I want the criteria for the customer in the "receipts" table to match the comboBox in the form. I am currently doing this like this in the design view of the query, under criteria for "customers" in receipts table:

Expand|Select|Wrap|Line Numbers
  1. =[Forms]![ReportBuilder_receiptsByCustomer]![ComboBox33]
This isn't working because I need the ComboBox to return the text value of the customer.name and not the integer value customer.id

How can I do this??

Thanks to all in advance
Aug 2 '08 #1
2 34917
missinglinq
3,532 Recognized Expert Specialist
[Forms]![ReportBuilder_receiptsByCustomer]![ComboBox33] is going to give you the value of ComboBox33; .Value is the Default Property of a combobox, so ComboBox33 is the same thing as ComboBox33.Value. The Value of a combobox is the value of the first field (also known as the bound field) reading left to right, in the combobox. Since the columns are zero-based Combo33.Value is the same as ComboBox33.Column(0) and reading your SQL statement, or looking at your combobox (if all fields are dispalyed) the first field or column is the ID field. The second field or column is the name, and since it's zero-based, would be Column(1) so

[Forms]![ReportBuilder_receiptsByCustomer]![ComboBox33].Column(1)

should yield the Customer Name you're looking form.

Linq ;0)>
Aug 3 '08 #2
NeoPa
32,557 Recognized Expert Moderator MVP
As Linq says, the Bound column is what is returned by default.

Try changing the .BoundColumn property to 2 as an alternative approach. This should make the .Value of the control reflect the Name you're after.
Aug 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
12066
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
6
4883
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
4
8607
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
2
8646
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
6
3484
by: Scotty | last post by:
Hi, I need some info How to return the value from the database My combobox Me.cboTypeAdres.Items.Add("Type Adres") Me.cboTypeAdres.Items.Add("Leverancier")...
1
1858
by: Jl_G_0 | last post by:
Hey all. I need to create a ComboBox with some strings on it, but when the user selects it, I want to have codes for each one of the strings, because the app is waiting Return in codes (but not...
2
7112
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
6
1273
KalariaNitya
by: KalariaNitya | last post by:
hello all, i need ur help.. i have 10 combobox & 10 textbox on windows forms it's names like : cmbsign1 txtdiscount1 cmbsign2 txtdiscount2
7
3564
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
2
14717
by: =?Utf-8?B?RHJEQkY=?= | last post by:
I understand that the Value put into a DataGridViewComboBoxCell has to be a member of the Items list or an exception is thrown. I also understand that you can override that exception by handling...
0
7086
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...
0
7280
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,...
0
7332
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...
0
7462
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...
0
4673
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
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 ...
1
736
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.