By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,472 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Get Value from a comboBox as text

P: 25
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
Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
[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
Expert Mod 15k+
P: 31,186
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

Post your reply

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