Board index » delphi » Help: Sorting and Range

Help: Sorting and Range

I have a DBGrid for displaying the table.
I would like to use something like a DBComboBox or a DBListBox to display
all of the records of a particular field.

Ex:   Lets say that I have a table which contains

    Cust No      Item Purchased      Date Purchased, etc...
    100               12/2WG Romex        12/30/97
    105                Computer                  06/25/98
    100                Kotex                         06/26/97
     ....                    ......
...............
     ....                    ......
...............
     ....                    ......
...............
     etc                    etc                            etc

I would like to use a component that will display the customer numbers
(uniquely sorted) so that the user will be able to select, from the
DBComboBox or DBListBox, one of the Cust No records.

This selection (double click) will refresh the DBGrid with records that
contain only the Cust No selected.

I am using SetRange  with the starting and ending values being equal.

I would appreciate any positive suggestions.

 

Re:Help: Sorting and Range


Hi Lawrence,

This might help you.

If I understand your question, you can use a DBLookupComboBox
to give you a drop down list of all the selections in a Field.

To do this use 2 tables pointing to the same database.

On your Form put:
  - Datasourse (DS1)
  - Table (T1) to your Database

  - Datasourse (DS2)
  - Table (T2) to the same Database

  - DBLookupComboBox with:
      DataField = F1 (the field you want the lookup on)
      DataSource = DS1

      KeyField = F1
      ListField = F1
      ListSource = DS2

You need 2 DataSources and 2 Tables otherwise you have a circular
reference.
It works great, with no code.
Good Luck,

Frank

Quote
Lawrence Leary wrote:
> I have a DBGrid for displaying the table.
> I would like to use something like a DBComboBox or a DBListBox to display
> all of the records of a particular field.

> Ex:   Lets say that I have a table which contains

>     Cust No      Item Purchased      Date Purchased, etc...
>     100               12/2WG Romex        12/30/97
>     105                Computer                  06/25/98
>     100                Kotex                         06/26/97
>      ....                    ......
> ...............
>      ....                    ......
> ...............
>      ....                    ......
> ...............
>      etc                    etc                            etc

> I would like to use a component that will display the customer numbers
> (uniquely sorted) so that the user will be able to select, from the
> DBComboBox or DBListBox, one of the Cust No records.

> This selection (double click) will refresh the DBGrid with records that
> contain only the Cust No selected.

> I am using SetRange  with the starting and ending values being equal.

> I would appreciate any positive suggestions.

Other Threads