Board index » delphi » Sorting DBGrid on calculated and lookup fields from ADOQuery

Sorting DBGrid on calculated and lookup fields from ADOQuery

I have a DBGrid showing fields from a ADOQuery.
The ADOQuery has fkCalculated and fkLookup fields.
Is it posible to Sort the DBGrid on these fields ?
I'm using Delphi 6.

Thanks in advance,

Willy Verbiest

 

Re:Sorting DBGrid on calculated and lookup fields from ADOQuery


Quote
>I have a DBGrid showing fields from a ADOQuery.
>The ADOQuery has fkCalculated and fkLookup fields.
>Is it posible to Sort the DBGrid on these fields ?
>I'm using Delphi 6.

No
If you can calculate in your query and use a join to link to your lookup field
they you will get fields you can sort on
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Sorting DBGrid on calculated and lookup fields from ADOQuery


Hello Brian,

Thanks for the hint.

I've removed the Calculated fields and the Lookup fields and constructed the
following SQL query string for the ADOQuery.

SELECT
  tblOrders.*,
  tblCustomers.CustomerName,
  tblProducts.ProductName,
  tblCountries.Country,
  TRIM(tblOrders.OrderNo) +
  TRIM(tblOrders.OrderLn) AS BatchRefNo,
  tblOrders.Quantity +
  tblOrders.QuantityExtra AS QuantityTotal
FROM tblOrders, tblCustomers, tblProducts, tblCountries
WHERE tblOrders.CustomerID = tblCustomers.CustomerID
AND tblOrders.ProductID = tblProducts.ProductID
AND tblCustomers.CountryID = tblCountries.CountryID

Now I can sort on any field I want.
I have put this in the newgroup as I got trouble to find out how to
construct the SQL and want to show this to the readers of the newsgroup.

Kind regards,
Willy Verbiest

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:s3fvev0ijf7rtp3b2uujah0jpob7t32cgn@4ax.com...

Quote

> >I have a DBGrid showing fields from a ADOQuery.
> >The ADOQuery has fkCalculated and fkLookup fields.
> >Is it posible to Sort the DBGrid on these fields ?
> >I'm using Delphi 6.
> No
> If you can calculate in your query and use a join to link to your lookup
field
> they you will get fields you can sort on
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Other Threads