Probably the find is not performed in the right context. Move the step Go to Layout ["NewPtReport" (PatientData)] to the top of the script and try again.
Set Field [ PatientData::FirstVisit ; Date ( Month ( Get ( CurrentDate ) ) ; 1 ; Year ( Get ( CurrentDate ) ) ) & "..." & Get ( CurrentDate ) ]
will find all the patients, which had the first visit in the current month.
Set Field [ PatientData::FirstVisit ; Date ( Month ( Get ( CurrentDate ) ) - 1 ; 1 ; Year ( Get ( CurrentDate ) ) ) & "..." & Date ( Month ( Get ( CurrentDate ) ) ; 0 ; Year ( Get ( CurrentDate ) ) ) ]
will find all the patients, which had the first visit in the last month.
Thanks for the reply but, i get an error message about invalid get function on the CurrentMonth.
That was an error that I sudden corrected...
Sorry but how do I paste your text into FM?
No intent to confuse things here, but you might want to consider finding all patients within the last 30days, rather than by what month they visited...you don't know what day of the month the script will run. This, of course, assumes that you WANT to find new patients within the last 30 days...you know your needs best, not me.
If this is what you want, consider changing your SetField step to:
Set Field [ PatientData::FirstVisit ; Get(CurrentDate)-30 & "..." & Get(CurrentDate) )
Again, this would ignore month starts and stops and simply give you patients over the last 30 days.
Just another option...
You can't paste an entire script copied as text from here or elsewhere into the script editor. That'd be nice, but can't do it with just FileMaker.
You can paste bits and pieces of it such as the second parameter of Raybaudi's set Field steps into a Specify Calculation dialog. Just be careful to make sure the pasted text matches the actual table and field names defined in your database or you'll get error messages.