Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
method pushButton(var eventInfo Event)
; ---------------------------------------------------------------
; This routine verifies that the user has selected a month and
; and then runs the report query.
; ---------------------------------------------------------------
var
loRetval Logical ; Flag indicating success or failure.
siQMonth SmallInt ; Holds the month the user wants to print.
sqlPrint SQL ; Query using the user's selection.
tcAnswer TCursor ; Holds results, for performance and eval.
dbTables Database ; Location of the tables for the query.
endVar
const
ERRTITLE = "Can't Print Birthday List" ; error dialog title.
endConst
; Let the user know something is happening and define vars.
setMouseShape( mouseWait )
doDefault
loRetval = TRUE ; Assume we'll succeed.
siQMonth = fldMonthList.theList.List.Selection - 1
; Next, point the database variable to the DATA alias.
dbTables.open( ":DATA:" )
; Now, see if the user chose the entire year, if so,
; we'll use a different SQL statement to create answer
; than we'd use for a specific month.
If siQMonth = 0 then
sqlPrint = SQL
Select Distinct
e."LastName", e."FirstName",
e."Department", e."BirthDate",
extract( Month from e."BirthDate" ),
extract( Day from e."BirthDate" )
from
":DATA:EMPLOYEE" e
EndSQL
else
sqlPrint = SQL
Select distinct
e."LastName", e."FirstName",
e."Department", e."BirthDate",
extract( Month from e."BirthDate" ),
extract( Day from e."BirthDate" )
from
":DATA:EMPLOYEE" e
where
( extract( Month from e."BirthDate" ) = ~siQMonth )
endSQL
endIf
errorTrapOnWarnings( No )
Message( "Selecting employees..." )
If not sqlPrint.executeSQL( dbTables, tcAnswer ) then
; The query could not be run, so display the error to the
; user and save the query in :PRIV: for support purposes.
errorShow( ERRTITLE,
"Reason: The query failed; see details..." )
sqlPrint.writeSQL( ":PRIV:BADQUERY.TXT" )
loRetval = FALSE
else
; The query ran, so see if we got any records.
If tcAnswer.nRecords() = 0 then ; no records returned
setMouseShape( mouseArrow )
msgStop( ERRTITLE, "No matches were found for your " +
"criteria. Please try a using a" +
"different selection." )
loRetval = FALSE
else
; create the ANSWER table
tcAnswer.instantiateView( ":PRIV:ANSWER.DB" )
endIf
endIf
; Save the criteria to an environment variable so the report
; can print it.
writeEnvironmentString( "RPTTITLE", fldMonthList.Value )
; Make sure the TCursor gets closed
If tcAnswer.isAssigned() then
tcAnswer.close()
endIf
; If the process succeeded, then close the form.
; Otherwise, stick around so the user can try again.
setMouseShape( mouseArrow )
if loRetval then
formReturn( True )
endIf
endMethod