473,804 Members | 3,809 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 35154
missinglinq
3,532 Recognized Expert Specialist
[Forms]![ReportBuilder_r eceiptsByCustom er]![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.Valu e. 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.Colu mn(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_r eceiptsByCustom er]![ComboBox33].Column(1)

should yield the Customer Name you're looking form.

Linq ;0)>
Aug 3 '08 #2
NeoPa
32,579 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
12120
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 combobox. What is the solution? Thank you in advance.
6
4919
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 are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
4
8645
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 tell me if this is even possible, and if so, how to do it? If this is completely impossible, how would you suggest going about sorting a ComboBox wherein the text displayed in the column is the client's name, and the underlying value is an ID? ...
2
8675
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 list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
6
3507
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") Me.cboTypeAdres.Items.Add("Klant")
1
1870
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 index of combobox). I was thinkin on doing it like this: cbItem.Text = "Text" cbItem.Idcode = "Code" But:
2
7158
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 filled in automatically by setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is set to the .Text value in the ID textbox. All works fine but it is ...
6
1304
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
3586
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 Me.cboLocation.Text = ""
2
14775
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 the DataError event and just doing nothing in the circumstance that caused the error. Here's my situation: I would like to allow the user to EITHER select an item from the ComboBox (in a DataGridView) OR type in a new value of their own.
0
9706
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
9577
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
10569
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10325
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...
0
10075
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...
1
7615
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
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
2
3815
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.