dbanbury Posted March 3, 2006 Posted March 3, 2006 Hi guys and girls (if any girls like databases, I don't know!) I'm new to FileMaker but not to databases in general. It's been some years since I used to write programs in FoxPro, but once I'd got into the swing of things, I found it quite pleasurable. So I think I have a reasonably good aptitude for relational databases and writing programs for them (don't know how many of you know it, but FoxPro Basic wasn't like FileMaker's scripting language - in FoxPro you HAD to include screen logic programming if you wanted your records to pause after 25 lines etc., you also had to rebuild indexes manually!) So the principles behind relational database operation aren't a problem for me to understand; what I'm having difficulty with is making FileMaker's script steps duplicate what I can do manually. I won't bother explaining now the context as it's long and complicated and knowing it won't help solve the core problem anyway. Here's the behaviour I observe with the mouse. If I am in a found set of records, or indeed am looking at all of them, when I click into find mode and enter something which I know can't be found, FileMaker presents an error message and allows me to continue or cancel. If I continue, I am taken to a found set of zero records. If I cancel, I am returned to the previous found or full set of records, whichever I was looking at prior to the failed find request. It is this last behaviour I wish to duplicate in a script. That is, if I was looking at all the records, I want to be returned to those, or if I was in a found set, I want to go back to that. Clearly a ShowAllRecords script step isn't suitable, since that will wipe a found set. Here is the part of the script I feel should duplicate this behaviour, but instead I am always taken to a found set of zero records. Set Variable [ $CurrentProductID ; Value:Product::ID ] # If the script is not called by a user clicking on a specific ProductOptionID, make sure there are related product options to go to. If [ Get ( ScriptParameter ) <> "SpecificLookup" ] Enter Find Mode Set Field [ ProductOption::ProductID ; $CurrentProductID ] Set Error Capture [ On ] Perform Find [ ] Set Variable [ LastError ; Value:Get ( LastError ) ] Set Error Capture [ Off ] If [ $LastError = 401 ] Beep Revert Record/Request Enter Browse Mode End If End If I've tried changing the actions taken in the last If test to deleting the Record/Request and I've also removed the Enter Browse Mode step to no avail. Any pointers where I'm going wrong will be much appreciated. P.S. Is there a way to export scripts as text from FileMaker Pro?
Vaughan Posted March 3, 2006 Posted March 3, 2006 The Revert Record/Request doesn't do w]hat you want -- it's more like "undo field edits". FMI has documented the change in find behaviour when there are no matching records -- it's different to FMP 6 and earlier. There are a couple fo ways of returning to a found set: one way is to open a new window and perform the find in the new window... the old window will have the old found set still intact. There may be other methods.
dbanbury Posted March 3, 2006 Author Posted March 3, 2006 Hi, thank you. Someone suggested running a PatternCount function on a value list to check whether a find will be successful. I was wondering whether this will result in slower operation than creating a duplicate table occurence and performing a find on that to leave the original set untouched. thoughts appreciated. Best wishes, Dave.
comment Posted March 3, 2006 Posted March 3, 2006 You don't need another TO. All you need is to open a new window. Each window has its own found set. Another option is to use a relationship to check if a related record exists (which is the equivalent of a find, and often quicker). I am afraid I didn't understand the idea with the PatternCount.
dbanbury Posted March 3, 2006 Author Posted March 3, 2006 Hi, thank you. The PatternCount idea has been dropped as it'll be slow on datasets of 100,000. Simple question, then, how do I test whether a parent record has any child records? Many thanks, Dave.
comment Posted March 3, 2006 Posted March 3, 2006 If your child records have serialIDs (as they should), and if the serialID field is a number, the test is very simple: If [Child::ChildID] If the field is text: If [not IsEmpty ( Child::ChildID )]
Recommended Posts
This topic is 6842 days old. Please don't post here. Open a new topic instead.
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