TDBGrid(s) Compare Values and Paint

On this form, there are (3) TDBGrids. OnCalcCellColors  or OnDrawDataCell, need to compare a value in grid1 with a corresponding value in grid3. The row color for all (3) grids will be determined by the comparison. >= Red, < Green etc...

The coloring is easy. However without ARow & ACol cell references, not sure how to index the values. Works great on a single grid.
Doing the comparison in this manner with negate the need to  Enumerate the data set.
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
i'm missing a few items

you have 3 grids and 1 comparison between grid 1 and 3 ?
why do you need grid 2 then ?
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
This is an Accounts Payable screen.

Grid1 holds the purchase order detail
Grid2 gets a copy of the purchase order data when a vendor invoice is entered
Grid3 holds the total paid on each line items, many times we get multiple Vendor Invoices on a single PO, and not all items may be received in one shipment.

The idea is to compare the Purchase Order Received Quantity and Approved amount, and total paid.
An attempt to enter an invoice amount in excess of the (Approved-Paid) with not be allowed.
line items paid in full will be colored red, those with remaining balances Green. Line items with no prices on the PO yellow.

I've done this sort of thing in a single grid before and it works great,OnCalcCellColors get called all the time. So the color updates seamlessly with keystrokes, also eliminating the need to enumerate that data sets.

Due to the way the data is laid out, evaluating the data row by row is really convenient as we always know which row the user is in.
Geert GOracle dbaCommented:
You are stating facts , when are the questions coming with the code ?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
The objective is to colorize all corresponding grid rows, based on ((Auth.AMt+Tot.Cost) <= Paid).
Just not sure how to go about it. Easily done in a String Grid or Single Grid.
And thank you Geert!
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
Adding  Auth.Amt & Tot.Cost as lookup fields to Paid dataset made it work in that grid, however with a minor performance hit.
Unless we come up with a better idea, pretty well decided to simply maintain all three values in all three tables. Since these are all ClientDataSets, the only real hit will be storage, which in my environment is a non-issue. Still open to suggestions
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
Not having found a simple way for the grids to be aware of each others content on a row by row basis during the on "ApdCalcCellColors" event.

Ultimately had to make the deciding column data avaiable in each individual data set, ie...
Puchased -> Invoiced ->Paid, where green indicates authorized purchase amount, red indicates invoice and or paid in full.
In the event to opperator tries to enter an amount, in excess of the authorized amount. The entire row gets a red background color.

Thank you for looking at this quest!

Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
Actually, a better illustration is when a purchase order has more than one invoice. Where not every item may be on each invoice, Ie, partially received or invoiced.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.