PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → BuildBrowsingTable function and displaying Totals of columns
BuildBrowsingTable function and displaying Totals of columns
Débuté par Sead Grbesic, 01 aoû. 2017 14:11 - 5 réponses
Posté le 01 août 2017 - 14:11
Greetings,

I am using BuildBrowsingTable to display content of selected query.
After BuildBrowsingTable function fills the table with content of the query, how can I display Total of selected columns?

Kind Regards,
Sead
Posté le 07 août 2017 - 00:36
I have a text control that I can write my query in then click the run button which opens the browsing table on a new page.
It has titles of field names from my query.



// MY code to run a script form a text box so can be

sQuery is string = [
SELECT * from fixnames
]

// Step 3 - Initializes the query for tmpTable
IF HExecuteSQLQuery(tmpTable,sQuery) THEN
Info("The query contains "+ numtostring(HNbRec(tmpTable)) + " records.")
ELSE
Error("Error while initializing the query" + CR + HErrorInfo())
INFOWITHTIMEOUT(3000,"Error while initializing the query", sQuery)
RETURN
END

// Step 4 - Read the first record of the query
hdeclareExternal("tmptable.fic","tmpTable")
HReadFirst(tmpTable)





??THIS CODE IN MY "RUN" BUTTON

// first clear table to ensure script returns latest results
TableDeleteAll(tbl_DataBrowse)


// Step 3 - Compile and run script result to browsing table
WHEN EXCEPTION IN
sRptSql is Procedure = Compile(edt_rptsql)
IF ErrorOccurred = False THEN
sRptSql()

IF HNbRec(tmpTable) > 0 THEN
InfoWithTimeout(300,"No of records in table = " + NumToString(HNbRec(tmpTable)))
BuildBrowsingTable(tbl_DataBrowse,tmpTable,taFillTable)

// prepare view table fro browsing table
PSHEET_View..Visible = False
TT_View..Visible = False
tbl_DataBrowse..Visible = True
RADIO_View = 1
Tab_RunReport = 9
ELSE
InfoWithTimeout(300,"No records in table" + " " + ErrorInfo())
END
ELSE
Info(" Script has returned a comple error "," ", Info(ErrorInfo()))
END

DO
Info(" Script has returned an exception error "," ", ExceptionInfo(),"---------------" )
END
Membre enregistré
3 messages
Posté le 07 août 2017 - 00:40
I have a text control that I can write my query in then click the run button which opens the browsing table on a new page.
It has titles of field names from my query.

My table_control just has 2 columns in it. Nothing special I dopnt think.

// MY code to run a script from a text box so can be

sQuery is string = [
SELECT * from fixnames
]

// Step 3 - Initializes the query for tmpTable
IF HExecuteSQLQuery(tmpTable,sQuery) THEN
Info("The query contains "+ numtostring(HNbRec(tmpTable)) + " records.")
ELSE
Error("Error while initializing the query" + CR + HErrorInfo())
INFOWITHTIMEOUT(3000,"Error while initializing the query", sQuery)
RETURN
END

// Step 4 - Read the first record of the query
hdeclareExternal("tmptable.fic","tmpTable")
HReadFirst(tmpTable)





??THIS CODE IN MY "RUN" BUTTON

// first clear table to ensure script returns latest results
TableDeleteAll(tbl_DataBrowse)


// Step 3 - Compile and run script result to browsing table
WHEN EXCEPTION IN
sRptSql is Procedure = Compile(edt_rptsql)
IF ErrorOccurred = False THEN
sRptSql()

IF HNbRec(tmpTable) > 0 THEN
InfoWithTimeout(300,"No of records in table = " + NumToString(HNbRec(tmpTable)))
BuildBrowsingTable(tbl_DataBrowse,tmpTable,taFillTable)

// prepare view table fro browsing table
PSHEET_View..Visible = False
TT_View..Visible = False
tbl_DataBrowse..Visible = True
RADIO_View = 1
Tab_RunReport = 9
ELSE
InfoWithTimeout(300,"No records in table" + " " + ErrorInfo())
END
ELSE
Info(" Script has returned a comple error "," ", Info(ErrorInfo()))
END

DO
Info(" Script has returned an exception error "," ", ExceptionInfo(),"---------------" )
END

--
Mark Crichton
DataWise Ltd
New Zealand
Posté le 08 août 2017 - 06:09
Hi
Would it not be ok to have a text control and calculate the totals on the columns you want. Could have a procedure that does that based on column types maybe
Posté le 08 août 2017 - 09:36
From WD22 you have a new function TableFormulaAdd

Online Help
Posté le 09 août 2017 - 13:28
Hi,

I will try to implement your method, and will post the results.

I bought WD22, but did not switch yet. I think that function will solve my problem the easy way. But until I switch to WD22 I have to find alternative way.

Kind Regards,
Sead