March 20, 200223 yr I use the following script, and it doesn't work, can anyone tell me why. I want to show records in a layout List view where the date is today and no later than a week in the future in date order. The Script Enter Browse Mode Sort Sort Order: StartDate Ascending Pickup Ascending Restore sort order, No Dialog Show All Records Goto Record/Request/Page First Loop If StartDate >= Today and StartDate < Today + 7 Omit Record End If Goto Record/Request/Page Next, Exit after last End Loop Show Omitted Goto Layout Due Out This is doing my head in, the programming to me looks fine, why can't Filemaker handle the script. Any suggestion would be appreciated. Thanks
March 20, 200223 yr Bear in mind that scripts should produce the same result effects as though youo had performed each task in order. If you perform your task by "hand" you'll find that the go to next record is unnecessary when the record was just omitted, because FM has removed the record from the found set and automatically advanced you to the next. Personally, I would Start from last check/omit as necessary if we didn't omit then go previous rec exit if we are at rec 1
March 20, 200223 yr The Script tidied up a bit and made to work: Enter Browse Mode Sort Sort Order: StartDate Ascending Pickup Ascending Restore sort order, No Dialog Show All Records Goto Record/Request/Page First Loop If StartDate >= Status(CurrentDate) and Status(CurrentDate)+7 > StartDate Omit Record Else Goto Record/Request/Page Next, Exit after last End If End Loop Show Omitted Goto Layout Due Out -------------------- However, consider this as a solution: Create a calculating text field (lets call it DATEFINDER) with the following calculation: Case( StartDate >= Status(CurrentDate) and Status(CurrentDate)+7 > StartDate, “x”, “”) Now create a find script: ----- Perform find, restore find requests Goto Layout Due Out ----- This looks for the value “x” in the field DATEFINDER and goes to the right layout! Hope this helps, Rigsby
March 20, 200223 yr Mark and Rigsby pointed out a very common mistake of using Omit in a Loop, i.e., when you Omit a record, the next record becomes the current record! So the Go to Next Record step skips every record following an Omit. Rigsby's script corrects this by adding the Else statement. I'm wondering, though, why not just script the Find to begin with? Enter Find Mode( ) Insert Calculated Result (StartDate, DateToText (Status(CurrentDate)) & "..." & DateToText (Status(CurrentDate) + 7)) Perform Find( )
March 20, 200223 yr Author Thanks a lot. all your methods worked, I've never used Insert Calculated result in find mode, I can think of loads of use for that, many thanks
Create an account or sign in to comment