|
Home > Archive > Getting Started with dBASE > November 2006 > Disable column in grid and summarize values
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Disable column in grid and summarize values
|
|
| Incoronata Pircio 2006-10-25, 7:23 am |
| I have two questions. Hope somebody could help me.
- I have a form with a grid. One of the column is a calculated field an I don´t want user be able to change the calculated value. I even would rather user could not have access tho than column at all. Just as works an entryfield with the property enabl
ed set to false. How can I do this?
- The other question is about the same column. This is a numeric fields and I want to sum all values and show total. Of course, total must change every time a row is added/removed. I have had some problems with this calculated field.
| |
| John Marshall 2006-10-25, 7:23 am |
|
Part II:
You can either write a routine to update a total triggered by Grid onSelChange, or you can write a query that uses parameters to match the scope of the grid contents.
Routine:
function SumCol(rSource,Dest)
local rSource, bm, nSum, aSum
bm = rSource.bookmark()
nSum = 0
if rSource.first()
rSource.notifyControls = false
do
nSum += rSource.fields["AMT"].value
until NOT rSource.next()
rSource.notifyControls = true
rSource.goto(bm)
endif
dest := nSum
return
OR
this.TOTAL1 = new QUERY()
this.TOTAL1.parent = this
with (this.TOTAL1)
left = 6.1429
top = 23.8182
database = form.db1
sql = "select sum(Amt) as Amount from Sales where TransDate = :mdate and CustID =:CID"
params["CustID"] = "1234"
params["TransDate"] = {05/15/2005}
active = true
endwith
Your grid onSelChange event might look like:
// set params to match grid rowset scope
Form.total1.params["CustID"] = form.GridDB.rowset.fields["CustID"].value
Form.total1.params["TransDate"] = form.GridDB.rowset.fields["TransDate"].value
Form.total1.requery()
// place total into control
Form.EntryField1.value = form.total1.rowset.fields["Amount"].value
JM
Incoronata Pircio Wrote:
> I have two questions. Hope somebody could help me.
> - I have a form with a grid. One of the column is a calculated field an I don´t want user be able to change the calculated value. I even would rather user could not have access tho than column at all. Just as works an entryfield with the property ena
bled set to false. How can I do this?
> - The other question is about the same column. This is a numeric fields and I want to sum all values and show total. Of course, total must change every time a row is added/removed. I have had some problems with this calculated field.
| |
| Incoronata Pircio 2006-11-01, 7:12 pm |
| Thanks John. I wrote function but I an not sure how to use it in my program. Function has two parameters and I don't know how to call it to return the total calculated.
Thanks again
John Marshall Wrote:
>
> Part II:
>
> You can either write a routine to update a total triggered by Grid onSelChange, or you can write a query that uses parameters to match the scope of the grid contents.
>
> Routine:
>
> function SumCol(rSource,Dest)
>
> local rSource, bm, nSum, aSum
> bm = rSource.bookmark()
> nSum = 0
> if rSource.first()
> rSource.notifyControls = false
> do
> nSum += rSource.fields["AMT"].value
> until NOT rSource.next()
>
> rSource.notifyControls = true
> rSource.goto(bm)
> endif
>
> dest := nSum
>
> return
>
> OR
>
> this.TOTAL1 = new QUERY()
> this.TOTAL1.parent = this
> with (this.TOTAL1)
> left = 6.1429
> top = 23.8182
> database = form.db1
> sql = "select sum(Amt) as Amount from Sales where TransDate = :mdate and CustID =:CID"
> params["CustID"] = "1234"
> params["TransDate"] = {05/15/2005}
> active = true
> endwith
>
> Your grid onSelChange event might look like:
> // set params to match grid rowset scope
> Form.total1.params["CustID"] = form.GridDB.rowset.fields["CustID"].value
> Form.total1.params["TransDate"] = form.GridDB.rowset.fields["TransDate"].value
> Form.total1.requery()
> // place total into control
> Form.EntryField1.value = form.total1.rowset.fields["Amount"].value
>
> JM
>
> Incoronata Pircio Wrote:
>
nabled set to false. How can I do this?[color=darkred]
>
| |
| John Marshall 2006-11-01, 7:12 pm |
|
Here is my call for the routine sent earlier:
form.sumcol(form.tip1.rowset,form.tiptotal.value)
// send rowset and destination field
Notice that I send it the rowset reference to the query (table) that I want to total. The second parameter is the entryfield on my form that displays the total. Notice that on the function side, this parameter takes ont he name 'Dest', and at the end of
the sum routine, the calculated total is passed back to the calling form with the assignment dest := nSum.
I hope this helps.
JM
Incoronata Pircio Wrote:
> Thanks John. I wrote function but I an not sure how to use it in my program. Function has two parameters and I don't know how to call it to return the total calculated.
> Thanks again
>
> John Marshall Wrote:
>
enabled set to false. How can I do this?[color=darkred]
>
| |
| Incoronata Pircio 2006-11-07, 7:13 pm |
| I wrote the routine before endclass but now, when the program starts, it stays in a loop. I put "msgbox" at the beginning of routine and it executes once and once again, so program doesn´t work.
What am I doing wrong?
John Marshall Wrote:
>
> Here is my call for the routine sent earlier:
>
> form.sumcol(form.tip1.rowset,form.tiptotal.value)
> // send rowset and destination field
>
> Notice that I send it the rowset reference to the query (table) that I want to total. The second parameter is the entryfield on my form that displays the total. Notice that on the function side, this parameter takes ont he name 'Dest', and at the end
of the sum routine, the calculated total is passed back to the calling form with the assignment dest := nSum.
>
> I hope this helps.
>
> JM
>
>
> Incoronata Pircio Wrote:
>
ty enabled set to false. How can I do this?[color=darkred]
>
| |
| Incoronata Pircio 2006-11-09, 7:14 pm |
| I wrote the routine before endclass but now, when the program starts, it stays in a loop. I put "msgbox" at the beginning of routine and it executes once and once again, so program doesn�t work.
What am I doing wrong?
Incoronata Pircio Wrote:
> Thanks John. I wrote function but I an not sure how to use it in my program. Function has two parameters and I don't know how to call it to return the total calculated.
> Thanks again
>
> John Marshall Wrote:
>
enabled set to false. How can I do this?[color=darkred]
>
|
|
|
|
|