Board index » delphi » LookUpField And DBGrid

LookUpField And DBGrid

Hi All,
Help,Help,Help,

I have same problem with lookup fields in dbgrid, how can you solved this
problem.
plase help me.
----------------------------------------------------------------------------
----
Well, after struggling for awhile (I'll never admit exactly how long)
trying to figure out why I couldn't filter a table based upon a lookup
field, I finally broke down and read the manual.
The DB App Developer's Guide states that lookup fields (or more
precisely - all persistent fields types) "are for display purposes only
and the data they contain at runtime are not retained...".
Does this mean that you can't use a lookup field to filter a table? It
seems logical (to me) that you should be able to.
Can someone help me out here. If you can't use a lookup field, does
someone have a logical alternative?
Here's my situation (or at least a representative sample):
Table1
- ------
Customer ID
Customer Name
  (etc)
Table2  (a particular agreement is associated with only one customer)
- ------
Agreement ID
Agreement Details
Customer ID
   (etc)
Table3  (a transaction for a given customer under a given agreement)
- ------
Transaction ID
Agreement ID
  <don't redefine Customer ID in physical DB because Agreement ID is
   sufficient to identify Customer>
Lookup Field - Customer ID
^^^^^^^^^^^^
   (etc)
The Customer ID lookup field in Table 3 uses the agreement ID and
matches with agreement id in Table2 to get the customer id.
All of my tables are Pdox.
Given the above, I want to filter Table3 based on a lookup combo of
all customer names. I am trying to code the OnFilterRecord for Table3
and check:
   Table3['Customer ID'] = Table1['Customer ID']
after user chooses a customer in the lookup combo. However, at runtime,
Table3['Customer ID'] in OnFilterRecord event is null for all records in
Table3.
Does anyone have any other ideas? This may be a simple problem, but this
is the first time I've been confronted with this and I can't seem to see
any other alternative than the one I'm trying to use.
Thanks for the help. I hope all of this makes sense.
Greg (Ramazan)

 

Re:LookUpField And DBGrid


Quote
>The DB App Developer's Guide states that lookup fields (or more
>precisely - all persistent fields types) "are for display purposes only
>and the data they contain at runtime are not retained...".
>Does this mean that you can't use a lookup field to filter a table?

Correct.

Quote
>Can someone help me out here. If you can't use a lookup field, does
>someone have a logical alternative?

Delphi 2 and 3 have an OnfilterRecord event where you can choose which
records to filter by any criteria you can code.   In your case you can
locate the record in the lookup table you are using and check the
value of the lookup field.

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Other Threads