The Monthly Sale Report Scripted ( Part 1 )

From Dwayne Wright - www.dwaynewright.com

In this discussion, I want to break down a monthly sales report script. Here is the script itself and I’ll break it down in another discussion. I’m adding the full script here, so I can refer to it in the other discussions.

#FIELDS REQUIRED -
#SET globals fields to current month and date in a dialog box

Set Field [ MonthySales::~sm_Month; Case(
Month(Get(CurrentDate)) < 10; "0" & Month(Get(CurrentDate));
Month(Get(CurrentDate))) ]

Set Field [ MonthySales::~sm_Year; Year(Get(CurrentDate)) ]

Show Custom Dialog [ Title: "REPORT BY MONTH SELECTION..."; Message: "Please enter in the month and year you want to report on."; Buttons: “OK”, “Cancel”; Input #1: MonthySales::~sm_Month, "Month"; Input #2: MonthySales::~sm_Year, "Year (all four digits)" ]

#CANCEL OPTION cancel script if the user chooses to do so from the dialog box.
If [ Get(LastMessageChoice) = 2 ]
Halt Script
Else
End If

#FIND months invoices
Set Error Capture [ On ]

Go to Layout [ “dev_Invoices” (MonthySales) ]

Enter Find Mode [ ]

Set Field [ MonthySales::Date; GetAsText(Date ( MonthySales::~sm_Month ; 1 ; MonthySales::~sm_Year) & "..." & Date
( MonthySales::~sm_Month + 1 ; 1 ; MonthySales::~sm_Year) -1) ]

Perform Find [ ]

#ERROR DETECTED - no matching records found
If [ Get ( FoundCount ) < 1 ]

Show Custom Dialog [ Title: "SEARCH ERROR"; Message: "No records were found matching your search settings."; Buttons:
“OK” ]

Go to Layout [ original layout ]
Halt Script

End If

#REPORT DISPLAY
Go to Layout [ original layout ]

New Window [ Name: "MONTHLY SALES REPORT"; Height: 50; Width: 50; Top: 50; Left: 50 ]

Show/Hide Status Area [ Show ]

Go to Layout [ “monthly sales report” (MonthySales) ]

Adjust Window [ Resize to Fit ]

Sort Records [ Specified Sort Order: MonthySales::Date; ascending ]
[ Restore; No dialog ]

Move/Resize Window [ Current Window; Height: Get ( WindowHeight ); Width: Get ( WindowWidth ) + 100 ]

Enter Preview Mode

Pause/Resume Script [ Indefinitely ]

#PRINT OR NO PRINT
Show Custom Dialog [ Title: "PRINT REPORT?"; Message: "Do you want to print this report?"; Buttons: “Yes”, “No” ]

If [ Get(LastMessageChoice) = 1 ]

Print Setup [ Orientation: Portrait; Paper size: 8.5" x 11" ] [ Restore; No dialog ]

Print [ Records being browsed; All Pages; Orientation: Portrait; Paper size: 8.5" x 11" ]
[ Restore ]

Else

End If

Close Window [ Current Window ]

Halt Script

=
More info about the author and FileMaker in general, contact me at info@dwaynewright.com.

© 2007 - Dwayne Wright - dwaynewright.com

The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.