Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type value of combo box

Status
Not open for further replies.

TimTDP

Technical User
Feb 15, 2004
373
ZA
In Access 2000 I have a combo box on a form based on a table.
The combo box is bound to the field SelectedProductId (Number, Long Integer)

The query for the combobox is:
SELECT tblProduct.ProductId, tblProduct.ProductCode, tblProduct.ProductDescription FROM tblProduct
ORDER BY tblProduct.ProductCode;

Column count = 3
Bound Column = 1

The query returns the correct data.
If the user selects a record from the combo box, the ProductId is stored correctly in the field SelectedProductId.

However when the combo box is displaying the records (drop down state), and the user tries to type in the ProductCode, the records displayed in the combo box are not narrowed down until the correct ProductCode is displayed.

Also, if the user types in the correct ProductCode, Access returns an error that the ProductId does not exist!

ProductCode is a text feild

What am I doing wrong?
 
What do you have for the properties "Limit To List" and "Auto Expand"? If you want a user to be able to enter a value not in your list, LTL must be "No"; If you don't have "Auto Expand" set to "Yes" the list will not narrow as you type.

Learn from the mistakes of others. You won't live long enough to make all of them yourself.
 
I do not want a user to enter a value not in the list.

"Limit To List" and "Auto Expand" are both set to "Yes"
 
I believe your combobox displays three columns that look something like:
1234 | Print123 | HP LaserJet

Since the first field is the ID field, but you want them to type in the Code, which is the second field, you need to change your sql to be:
SELECT tblProduct.ProductCode, tblProduct.ProductID, tblProduct.ProductDescription FROM tblProduct
ORDER BY tblProduct.ProductCode;

Then change the bound column to 2 instead of 1.

Learn from the mistakes of others. You won't live long enough to make all of them yourself.
 
I found my problem!
The first record on the combo box recordset was blank (null)
As soon as I corrected this, the combo box worked
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top