Home All Groups Group Topic Archive Search About

Query based of a value in a combo box

Author
22 May 2006 3:36 PM
Tony A.
The application I'm working on has three tables State, Customer, Orders.  In
the first combo box the State is selected.  Based on the State selected the
second combo box will be populated with the Customers in that state.  Based
on the Customer selected a datagrid will be populated with the customer's
orders.

I setup the query for the secont combo box as follows:
   Select CustName From tblCustomer
   Where State = @cboState

When I run this no records are selected.  Any suggestions on what I am
missing or forgetting?  Thanks...

--
Tony

Author
22 May 2006 4:37 PM
Ken Tucker [MVP]
Hi,

         I would check that you are passing the right value to your query. 
If your combobox is bound to a datatable the selected item will be a
datarowview not the string shown in the combobox.

Ken
-----------------

Show quoteHide quote
"Tony A." wrote:

> The application I'm working on has three tables State, Customer, Orders.  In
> the first combo box the State is selected.  Based on the State selected the
> second combo box will be populated with the Customers in that state.  Based
> on the Customer selected a datagrid will be populated with the customer's
> orders.
>
> I setup the query for the secont combo box as follows:
>    Select CustName From tblCustomer
>    Where State = @cboState
>
> When I run this no records are selected.  Any suggestions on what I am
> missing or forgetting?  Thanks...
>
> --
> Tony
Author
22 May 2006 6:53 PM
Tony A.
Ken,

The combo box is configured as follows:

    Name:                                   cmbCustName
    DataSource:        TblCustomerBindingSource1
    DisplayMember:            CustName
    VauleMember:        CustName
     SelectedItem:        TblCustomerBindingSource1 - CustName

I declared a variable - Dim varCustNmae as String

After the State combo box is changed I have teh following code:
    varCustName = cboState.SelectedValue

--
Tony


Show quoteHide quote
"Ken Tucker [MVP]" wrote:

> Hi,
>
>          I would check that you are passing the right value to your query. 
> If your combobox is bound to a datatable the selected item will be a
> datarowview not the string shown in the combobox.
>
> Ken
> -----------------
>
> "Tony A." wrote:
>
> > The application I'm working on has three tables State, Customer, Orders.  In
> > the first combo box the State is selected.  Based on the State selected the
> > second combo box will be populated with the Customers in that state.  Based
> > on the Customer selected a datagrid will be populated with the customer's
> > orders.
> >
> > I setup the query for the secont combo box as follows:
> >    Select CustName From tblCustomer
> >    Where State = @cboState
> >
> > When I run this no records are selected.  Any suggestions on what I am
> > missing or forgetting?  Thanks...
> >
> > --
> > Tony