Subject |
Re: requery problem (semi reason) |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Thu, 9 Jan 2020 10:31:01 +0200 |
Newsgroups |
dbase.getting-started |
On 09/01/2020 03:36, charlie wrote:
> OK I have a theory on what is happening but not sure why.
>
> If I put code that populates the entryfields with data and the requery in the same function such as form ongot focus, the problem persists with the form freezing and closing with the windows error.
>
> But if I put the code in the onopen function of the form and leave the requery in the ongotfocus for the form I have no problem. (Other than the entry fields don't get updated correctly.
>
> So here are the queries and the code below. Can anyone give a reason that this is happening so I can fix it? Thanks much for putting up with this.
>
I can't tell why but at least I can suggest a way to fix it.
Firstly move the code to calculate the count and total for each category
from the form's onOpen event handler into it's own function. Execute
the calculate_totals function from the form's onOpen event handler.
This takes you back to square 1. :-)
In the form's onGotFocus event handler do the requeries and then execute
the calculate_totals function. This takes care of the totals.
function form_onOpen()
set procedure to test.pop additive
form.popupMenu := new testpopup(form,"testPOPUP")
class::calculate_totals()
return
function form_onGotFocus()
form.master1.requery()
form.master2.requery()
form.master3.requery()
form.master4.requery()
form.master5.requery()
form.master6.requery()
form.master7.requery()
form.master8.requery()
form.master9.requery()
form.master9.rowset.first() //shouldn't be necessary but does no harm
class::calculate_totals()
return
function calculate_totals
sel = 0.00
cnt = form.master2.rowset.count()
form.entryfield3.value = cnt
if cnt # 0
do while not form.master2.rowset.endofset
sel = form.master2.rowset.fields["sell"].value +sel
form.master2.rowset.next()
enddo
form.entryfield4.value = sel
else
form.entryfield4.value = 0.00
endif
cnt = 0
sel = 0.00
cnt = form.master3.rowset.count()
form.entryfield9.value = cnt
if cnt # 0
do while not form.master3.rowset.endofset
sel = form.master3.rowset.fields["sell"].value +sel
form.master3.rowset.next()
enddo
form.entryfield10.value = sel
else
form.entryfield10.value = 0.00
endif
cnt = 0
sel = 0.00
cnt = form.master4.rowset.count()
form.entryfield1.value = cnt
if cnt # 0
do while not form.master4.rowset.endofset
sel = form.master4.rowset.fields["sell"].value +sel
form.master4.rowset.next()
enddo
form.entryfield2.value = sel
else
form.entryfield2.value = 0.00
endif
cnt = 0
sel = 0.00
cnt = form.master5.rowset.count()
form.entryfield5.value = cnt
if cnt # 0
do while not form.master5.rowset.endofset
sel = form.master5.rowset.fields["sell"].value +sel
form.master5.rowset.next()
enddo
form.entryfield6.value = sel
else
form.entryfield6.value = 0.00
endif
sel = 0.00
cnt = form.master6.rowset.count()
form.entryfield7.value = cnt
if cnt # 0
do while not form.master6.rowset.endofset
sel = form.master6.rowset.fields["sell"].value +sel
form.master6.rowset.next()
enddo
form.entryfield8.value = sel
else
form.entryfield8.value = 0.00
endif
return
Mervyn.
|
|