Diegushra Posted May 17, 2008 Share Posted May 17, 2008 Hi there! I've have a troublesome script, I need to do an automatic actualization of a group of records, when a related record gets updated. Let me explain: I have 3 tables with records, an a fourth table where records are generated with data of the 3 first tables, and what I need to do is whenever a record on any of the 3 first tables gets updated, the fourt table gets updated too. I did an script, is the following If [Table_4::Price4 ≠ Table_3::Price3] Show Custom Dialog ["The Data on Table_3 has been updated. You wish to update the records on Table_4?" If [Get (LastMessageChoice) = 2 Relookup Field Contents [No Dialog; Table_4::ID_Table3] End If If [Get (LastMessageChoice) = 1 Goto Layout [Table_4] End If End If Where ID_Table3 is the related field between Table_4 and Table_3, the thing is that the Script shows me every time the Custom Dialog, even if the records are updated smiley-undecided If anyone can help please!! Thx!!! Link to comment Share on other sites More sharing options...
LingoJango Posted May 17, 2008 Share Posted May 17, 2008 Are the Price fields you're comparing both set up as number fields? Are they actually identical? Can you see data from the related table in a portal? I certainly sympathize with your relationship troubles. By now I would've thought I had this relationship thing down pat, but when it isn't the wrong field type it's a glaring mistake with a Date calculation (thanks to the somewhat illogical - though perfectly normal to Americans - month-day-year sequence used in FM). Link to comment Share on other sites More sharing options...
AHunter3 Posted May 17, 2008 Share Posted May 17, 2008 Are the Price fields you're comparing both set up as number fields? Are they ...the somewhat illogical - though perfectly normal to Americans - month-day-year sequence used in FM). You're not stuck wtih that, you know! You can set the date format that should be native to any new file you create: whatever your operating system format is for date will be inherited by the database. And if you've acquired a db created by someone else who was using American date format, you can make a CLONE of it and the clone will acquire YOUR dat format, and then you can import all the data. (And the data ITSELF is in neither format, it is stored as a date-serial in which 1 = January 1 of the year 1 etc.) Link to comment Share on other sites More sharing options...
LingoJango Posted May 17, 2008 Share Posted May 17, 2008 Sorry, Allan, I wasn't referring to the format per se, which I've learned to deal with pretty well (and even produced a custom function for multi-language date output, which I needed!) - I was referring to the mistakes I make when I enter date calculations such as Date ( Day ( datefield ) ; Month ( datefield ) +1 ; Year ( datefield ) ) and only realize quite a while later that I should have inverted the day and month bits. Link to comment Share on other sites More sharing options...
AHunter3 Posted May 17, 2008 Share Posted May 17, 2008 Hmm, hadn't thought of that. Interesting... question: what do you get, on a system that has non-US date format as its native format, if you use GetAsDate (Day (datefield) & "/" & Month (datefield) + 1 & "/" & Year (datefield) ) ?? Does GetAsDate expect American month/day/year format, or does it respect the local date format? Link to comment Share on other sites More sharing options...
LingoJango Posted May 17, 2008 Share Posted May 17, 2008 Well, in data viewer it expects the local format. I tried your calc using Get ( CurrentDate ) and got a question mark till I reversed the elements. I knew there was a reason I didn't particularly like the GetAsDate function! :-) Link to comment Share on other sites More sharing options...
Diegushra Posted May 18, 2008 Author Share Posted May 18, 2008 Are the Price fields you're comparing both set up as number fields? Are they actually identical? Can you see data from the related table in a portal? Well, the Price3 in the Table_3 it's a calculation, and the Price4 in Table_4 is a Lookup Value of Price3, and yes they show in a portal.. But I have to relookup the Price4 field every time the Price3 in the Table_3 gets modified.. Link to comment Share on other sites More sharing options...
LingoJango Posted May 18, 2008 Share Posted May 18, 2008 So in other words, the statement If [Table_4::Price4 ≠ Table_3::Price3] evaluates as true even if the records are already up to date, the two fields of the same type, and the contents of the two fields supposedly identical? If that is the case, I'm flummoxed. Sorry! BTW, I apologize for unintentionally hijacking your thread. Link to comment Share on other sites More sharing options...
Diegushra Posted May 18, 2008 Author Share Posted May 18, 2008 That's correct, I'm lost with it too... So if anyone has a diferent aproach to the problem I'll be eternally grateful!! And no problem with the hijacking smiley-wink Link to comment Share on other sites More sharing options...
HBMarlowe Posted May 19, 2008 Share Posted May 19, 2008 So in other words, the statement If [Table_4::Price4 ≠ Table_3::Price3] evaluates as true even if the records are already up to date, the two fields of the same type, and the contents of the two fields supposedly identical? I was wrestling with a similar issue a while back, and it drove me nuts until I contrived to put a zero in one of the fields. Then it evaluated as false. That told me that from the current perspective the other field was not actually accessible. Is there any possibility that you have the same situation? Link to comment Share on other sites More sharing options...
Diegushra Posted May 20, 2008 Author Share Posted May 20, 2008 Well, let me checkt that, I'll see what happens... BTW Thanks everyone for the advices, I hope to solve this issue soon.. THX Link to comment Share on other sites More sharing options...
HBMarlowe Posted May 20, 2008 Share Posted May 20, 2008 If [Table_4::Price4 ≠ Table_3::Price3] You have not said what layout (context) you have at this point in your script, but I think this is where your problem is. Make sure that you have the correct table occurrences selected for Table_4 and Table_3 at this point. Link to comment Share on other sites More sharing options...
Diegushra Posted May 20, 2008 Author Share Posted May 20, 2008 You have not said what layout (context) you have at this point in your script, but I think this is where your problem is. Make sure that you have the correct table occurrences selected for Table_4 and Table_3 at this point. Well...the Table_4 has 2 layouts, one in form view and another in list view, same case with the Table_3. In the form view of Table_4 is where the lookup fields are present. Link to comment Share on other sites More sharing options...
Diegushra Posted May 20, 2008 Author Share Posted May 20, 2008 You have not said what layout (context) you have at this point in your script, but I think this is where your problem is. Make sure that you have the correct table occurrences selected for Table_4 and Table_3 at this point. Well...the Table_4 has 2 layouts, one in form view and another in list view, same case with the Table_3. In the form view of Table_4 is where the lookup fields are present. Link to comment Share on other sites More sharing options...
HBMarlowe Posted May 20, 2008 Share Posted May 20, 2008 Well...the Table_4 has 2 layouts, one in form view and another in list view, same case with the Table_3. In the form view of Table_4 is where the lookup fields are present. Which layout are you on at the point in the script when the If [Table_4::Price4 ≠ Table_3::Price3] occurs? What is the name of the table occurrence is it based upon? (Look in Layout menu > Layout Setup) Is there a relationship (in the relationship graph) between that table occurrence and the other table? What is the name of the related table occurrence? Those TO names must be used in the "If" script step. By the way, if you become a member here you can upload a screenshot of your relationships graph. That would be very helpful to anyone trying to help you now, or in the future. Good luck! Link to comment Share on other sites More sharing options...
Diegushra Posted May 21, 2008 Author Share Posted May 21, 2008 Thanks HBMarlowe, The name of the table occurrence are correct, I've checked the Layout Setup. Exists a working relationship between both tables through an ID field. Maybe the problem is that the script is in the parent Table? The DB structure is this: 3 different Tables with unique data on it, another table who shows data from the 3 tables. These 3 tables are the parent tables an the fourth is the child table Link to comment Share on other sites More sharing options...
HBMarlowe Posted May 21, 2008 Share Posted May 21, 2008 Exists a working relationship between both tables through an ID field. Maybe the problem is that the script is in the parent Table? The script is not "in" a table. It may be initiated by a button on a certain layout, or run from the Scripts menu, but at any point during the execution of the script everything is evaluated from the perspective of a particular table occurrence. I think the problem is that FileMaker cannot see both Table_3 and Table_4 at the same time from whatever layout it is on when the "If" step occurs. You might need to insert a "Go to layout" step just before the "If" step. You can later use another "Go to layout" step to return to your original layout. Link to comment Share on other sites More sharing options...
Diegushra Posted May 22, 2008 Author Share Posted May 22, 2008 Thanks HBMarlowe I'm going to try that!!! I'll keep you informed.. Link to comment Share on other sites More sharing options...
Recommended Posts