Subject Re: requery problem (semi reason)
From Heinz Kesting <Nobody@Nowhere.com>
Date Tue, 21 Jul 2020 14:11:19 +0200
Newsgroups dbase.getting-started

Hi Mervyn,

> ***** 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()
>

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()
    ...
else
    msgbox('No records to print in batch.dbf','Warning',64)
endif

Certainly no big deal, just a thought ...

>    if form.batch1.rowset.count = 0
>       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
>       _app.databases[ 1 ].emptyTable( "Batch" )
>       //The following will only work if batch.dbf is not open in another
> form
>       use batch exclusive
>       zap
>       use
>       form.batch1.active = true
>       //The rowset is empty but let's leave things as we found them.
>       //As the rowset is empty clicking on the pushbutton now will show the
>       //"No records" message.
>     endif
>     return
> **** End ****
>

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?

Thanks, and kind regards, Heinz