Combo Box

T

Tony K

I want to know how to have the drop down values of the combo box display
something different than what the box is bound to.

Example:
When the box is not in a 'drop down' state, it will display the Purchase
Order Number (it does this now).

How would I make it display the Purchase Order Number + " | " + SupplierName
when it is in drop down state? Then, when the item is selected it reverts
back to showing just the PO Number in the combo box.

My query that I would use is:

SELECT [Purchase Orders].DateReceived, [Purchase
Orders].DateRequired, [Purchase Orders].EmployeeID, [Purchase
Orders].FreightCharge,
[Purchase Orders].OrderDate, [Purchase
Orders].PurchaseOrderClosed, [Purchase Orders].PurchaseOrderDescription,
[Purchase Orders].PurchaseOrderID,
[Purchase Orders].PurchaseOrderNumber + " | " +
Supplier.SupplierName AS PONum, [Purchase Orders].ShipDate, [Purchase
Orders].ShippingMethodID, [Purchase Orders].SupplierID
FROM ([Purchase Orders] INNER JOIN
Suppliers ON [Purchase Orders].SupplierID =
Suppliers.SupplierID)
WHERE ([Purchase Orders].PurchaseOrderClosed = 0)


I tested this in Access and my column displays it correctly. How would I
implement this into my VB form.
 
C

Cor Ligthert[MVP]

Tony,

Will you tell us how you did it in VB.Net, because the SQL strings does not
say much about the combobox behaviour. It is a combobox, that has many
combinations how to use.

Cor
 
T

Tony K

I haven't done it in vb.net. I want to know how. In access, the column
will show the PO # & Supplier like the SQL statement shows.

I don't know enought about binding the combo box in a way to show 2 columns
of data... or one column using the AS statement in the SQL statement.
 
R

rowe_newsgroups

I haven't done it in vb.net. I want to know how. In access, the column
will show the PO # & Supplier like the SQL statement shows.

I don't know enought about binding the combo box in a way to show 2 columns
of data... or one column using the AS statement in the SQL statement.

You bind two fields for the combobox, the DisplayMember and
ValueMember, which allow you to display one thing, but retrieve a
different value using the SelectedValue property.

Thanks,

Seth Rowe
 
J

Jack Jackson

You bind two fields for the combobox, the DisplayMember and
ValueMember, which allow you to display one thing, but retrieve a
different value using the SelectedValue property.

Thanks,

Seth Rowe

I don't think that's what the OP wants - I think he wants the list
when dropped down to show something different from what the combobox
shows when it is not dropped down.
 
C

Cor Ligthert[MVP]

Jack,

If the OP makes from two database items one resultset item by his SQL
Select, then in every tool it will be showed as one item, even in Access.

Cor
 
R

rowe_newsgroups

I don't think that's what the OP wants - I think he wants the list
when dropped down to show something different from what the combobox
shows when it is not dropped down.

In that case he could handle the SelectedIndexChanged event of the
combobox and reassign the Text property to the appropriate values
whenever the user chooses a different item. This however differs from
the default behavior of a combobox and should be avoided as it will
(imo) cause confusion and frustration among the user base. In general,
users do not like unfamiliar behavior, and will often avoid using an
application that does not operate with the usual behavior.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top