emmade Posted November 24, 2004 Posted November 24, 2004 Hi What I want to do: Database for keeping track of electricity use. So take start reading take end reading en use the outcome of end reading - start reading. The following day I create a new record and the start reading is the end reading from the previous day. But I do not seem to get it working! I can use the option value from previous record but that is the same field and not the value of the end reading field from the previous record. can someone give me a direction to find a sollution for this? thanks! emma
Ender Posted November 24, 2004 Posted November 24, 2004 Here's one solution: Assuming you have a CustomerID field in there (to distingush between different customer's readings,) create a self join relationship: ReadingSelfJoin= Reading::CustomerID = Reading::CustomerID sort the relationship by StartReadingDate, decending. Now make the StartReadingDate a lookup = ReadingSelfJoin::EndReadingDate
emmade Posted November 28, 2004 Author Posted November 28, 2004 First at all thanks! But it is not working for me. Adding a second record works great but as soon I start the third record it takes the value of record is it possible that you make a small setup or have a look at my file? thanks a lot! emma
Ender Posted November 28, 2004 Posted November 28, 2004 Enclosed is a simple example. When you create a new record for an existing ID, it auto enters the end date from the latest record. AutoEnterExample.fp5.zip
RalphL Posted November 28, 2004 Posted November 28, 2004 I am attaching a file originated by John Mark Osborne and modified by me. John Mark & exchanged e-mails about which was correct. Neither of us concided. You can download the original from his site. LULAST.FP5.zip
Ender Posted November 28, 2004 Posted November 28, 2004 Hey Ralph, I can see how your solution works when the file has only one customer's records, but I think it would need some modification to work for multiple customers (though it is not clear if emma needs it to work for multiple customers.) I would also be concerned about the possibility of an entry being made out of order.
RalphL Posted November 28, 2004 Posted November 28, 2004 The problem I see with you method is re-lookups. If you need to make a change the re-lookup would put the same value in all the records for a customer.
Ender Posted November 28, 2004 Posted November 28, 2004 Good point. Then how about using the same self-join, but use an auto-entered calc instead of the Lookup: Start Date (date, auto-enter calc) = SelfJoin::EndDate
RalphL Posted November 28, 2004 Posted November 28, 2004 That should work. Wouldn't it preclude any auto updates?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now