| Subject |
Re: requery problem (semi reason) |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Tue, 21 Jul 2020 16:58:53 +0200 |
| Newsgroups |
dbase.getting-started |
On 2020-07-21 14:11, Heinz Kesting wrote:
> Hate to correct you, but I'm afraid some brackets are missing here (gr)
> ....
> shouldn't it read
>
> if form.batch1.rowset.count() = 0
>
> But anyway, I would prefer to compact and change this to
>
> if form.batch1.rowset.first() // there is at least one row in the set
> ChoosePrinter()
You're right of course. Mind you I did say the code hadn't been tested
but I definitely should know better than to leave the brackets out.
>
> I don't understand why you empty the table twice, first using
> emptyTable() and then again ZAP? Are these different tables or what I am
> missing here?
>
A moment of mental aberration on my part. I'd forgotten that the
emptyTable() method combines ZAP and PACK. :-( I'd actually intended to
PACK the table at that point.
Tony, the revised event handler follows. Watch for line wrap. Web-News
is the culprit. Other news readers are more civilised and fold lines
rather than introducing carriage returns and line feeds.
***** Start ******
function PUSHBUTTON1_onClick()
// Print Batch Report for Batcher
LOCAL FormName,BatchSize
ingnum = 0 //what is this for?
// Set up printer for report on Batch Ingredients
form.batch1.rowset.first()
if form.batch1.rowset.first()
msgbox('No records to print in batch.dbf','Warning',64)
else
choosePrinter()
_copies=2
_peject="None"
_plineno=3
_pmargin=3
ingnum = 3 //? what does this do?
set printer on
// msgbox("Printer On")
set margin to 10
FormName = form.batch1.rowset.fields["FormName"].value
BatchSize = form.batch1.rowset.fields["BatchSize"].value
//We need these values for the header and the rows of the report
fbrf = form.batch1.rowset.fields
// fbrf is a shortcut to save typing later and to limit length for
? command
printjob
? " " + FormName + Date()
?
?
? " Ingredient Amt" + " Stock Code " + " Batch Size "
?
?
do while not form.batch1.rowset.endofset //loop through table
? fbrf["ingrval1"].value Picture "999.999" + " " +
fbrf["scode1"].value + " " + BatchSize
form.batch1.rowset.next()
enddo
endprintjob
close printer
set printer off
//If we got this far there were records in batch.dbf. Let's get
rid of them.
//Make the query using batch.dbf inactive
form.batch1.active = false
//The following will only work if batch.dbf is not open anywhere else
_app.databases[ 1 ].emptyTable( "Batch" )
//The rowset is empty but let's leave things as we found them.
form.batch1.active = true
//As the rowset is empty clicking on the pushbutton now will show the
//"No records" message.
endif
return
***** End *****
Mervyn.
|
|