script to find invoices
I am trying to write a script to find all the invoices that have invoice dates between two dates supplied by the user but struggling.Any thoughts ? thanks
By hand or in a script?
The steps are the same, but the details differ a bit:
----------------- START QUOTE -------------------
"I am trying to write a script to find"
------------------ END QUOTE --------------------
Think he means with a script by his wording. I would be interested in this also. I need to modify a record in a related table via it's ID, without changing the current layout. So answering his question will answer mine. hehehe
Sometimes I miss stuff.
First the user has to specify the date range. Simplest approach is to put two fields with global storage on a layout somwhere: gDate1 and gDate2.
Enter Find ModeSet Field [Invoices::InvoiceDate ; Invoices::gDate1 & "..." & Invoices::gDate2 ]Set Error capture [on]Perform Find
I have done that and when I run my script, Filemaker just enters Find mode. It does not return any lines of data. Any thoughts ? thanks
make sure you have
Enter Find Mode
Enter Find Mode [pause]
clear the pause check box to keep the script from pausing in find mode.
If you want to do this action behind the scenes in a table other than the one represented on your current layout would you "Freeze" the window?
Yes. And check for no found records, and handle that scenario nicely for the user. Extending Phil's suggestion:
Enter Find Mode Set Field [Invoices::InvoiceDate ; Invoices::gDate1 & "..." & Invoices::gDate2 ] Set Error capture [on] Perform Find
If (Get (FoundCount ) = 0
Show Custom Dialogue ["There are no Invoices between " & gDate1 & " and " & gDate2 ]
Show All Records
Go to InvoiceListView
Thanks. However it is now returning all the records rather than just the those that should be in the find set. Any thoughts ?
Did it work before?
Did you make sure the 'Show All Records' is before the End If?
it appears to never been working. just didn't realise it. Get(foundcount) always returns the number of records in the dataset rather than the size of the findset. thanks
So, you ran Phil's script, and it simply returns all the records in the file?
What happens if you manually Find in the Invoices table for that date range (for the dates gDate1 and gDate2)?
Retrieving data ...