Marcos, If you don't already have one, you need a panel link (it can be hidden) in the Inventory panel that links to the Purchases panel. You also need a field in the Purchases panel (it also can be hidden) that updates on any change to the following formula:
0 - P2F1 (assuming P2F1 is your 'date of purchase' field) The panel link should link on the Item name only, and it should use an index in the Purchases panel that consists of the Item name first, followed by that reverse date field. If you want, the index can also include other fields after the first two but only the first two are needed for the link to work properly. Now the 'Cost of most recent purchase' field in your Inventory panel will have a formula like this on it: P1F4P2F4 (assuming P1F4 is the field number of the panel link in the Inventory panel, and P2F4 is the field number of the 'Purchase Cost' field in the Purchases panel). Set this formula to update on any change. Unless you absolutely have to use it in an index, you should make this 'Cost of most recent purchase' field in the Inventory panel be a "computed value field" using the ::C field format suffix (i.e. something like G$ZZZ,ZZ9.99::C). This makes the field formula get calculated whenever you display or access the record so that it always has the correct value. Otherwise if the field is a "real value" field (without the ::C), it only gets updated whenever a change is made to the record. Tim Rude "Marcos Favero Florence de Barros" <[email protected]> wrote in message news:[email protected]... > Hi, > > Although I read the "Using Keep A Total to Update Records in > Foreign Panels" section in Ralph Alvy's book, I'm not sure about > how to handle the following situation. > > In the Inventory Control section of a database, there is: > > (1) an 'Inventory' panel with: > > Item name _______________ > Quantity now in stock _____ units > Cost of most recent purchase $ _____ > > > (2) a 'Purchases' panel with: > > Date of purchase __/__/____ > Item name _______________ > Quantity purchased _____ units > Purchase cost $ _____ > > The 'quantity purchased' field of the second panel is used to > update the 'quantity now in stock' field of the first panel via a > keep-a-total, as usual. > > Now, I would like to have another automatic update here, namely > copying 'Purchase cost' of the second panel into 'Cost of most > recent purchase' of the first panel. This would be similar to > keep-a-total except that the number should not be added or > subtracted, but just copied. > > Is that possible? > > (An accounting note: We need the cost of the *most recent* > purchase because we are going by the so-called LIFO, or Last In > First Out, criterion for the cost of merchandise sold.) > > Here is another way to frame the same question. Suppose we have a > window in the first panel, with a single line, displaying records > of the second panel in reverse order (i.e., just the last record > appears), and showing just one field: 'purchase cost'. This is > exactly the information I want to be in the first panel -- only, > not in a window, but in a real field. > > Thanks, > > Marcos _______________________________________________ Dataperf mailing list [email protected] http://lists.dataperfect.nl/mailman/listinfo/dataperf
