Subject Re: requery problem (semi reason)
From Tony H <tamarak1@bigpond.com>
Date Tue, 21 Jul 2020 00:58:54 -0400
Newsgroups dbase.getting-started

I have written the following code and need to "empty Table" after the print is finished - The code included does it all except emptying the table for next printing session. A couple of trial coding at the end but I get errors. I need to change from "query" to exclusive use I think, but not sure how ??

Tony h



function PUSHBUTTON1_onClick()
   // Print Batch Report for Batcher  
                
        Public Ingnum, Batchsize, FormName
                Public Pcode1, Pcode2, Pcode3, Pcode4, Pcode5, Pcode6, Pcode7, Pcode8
                Public Pcode9, Pcode10, Pcode11, Pcode12,Pcode13, Pcode14, Pcode15
                Public ingrval1, ingrval2, ingrval3, ingrval4, ingrval5, ingrval6
                Public ingrval7, ingrval8, ingrval9, ingrval10, ingrval11, ingrval12
                Public ingrval13, ingrval14, ingrval15, rCount, pCount, dCount
                FormName = " "
                
                use EXCLUSIVE batch.dbf
                
                // form.rowset = form.batch1.rowset
                
                ingnum = 0
                // Set up printer for report on Batch Ingredients
                form.batch1.rowset.first()
                rCount = form.batch1.rowset.count()
                // rCount = 6
                pCount = rCount
                dCount = rCount
                form.Batch1.rowset.first()
                if rCount > 0        
                FormName = form.batch1.rowset.fields["FormName"].value
                BatchSize =        form.batch1.rowset.fields["BatchSize"].value
                Scode1 = form.batch1.rowset.fields["Scode1"].value
                Ingrval1 = form.batch1.rowset.fields["ingrval1"].value
                
                form.batch1.rowset.next()
                rCount = rCount -1
                endif
                        if rCount > 0
                        Scode2 = form.batch1.rowset.fields["Scode1"].value
                   Ingrval2 = form.batch1.rowset.fields["ingrval1"].value
                        
                        form.batch1.rowset.next()
                        rCount = rCount -1
                        endif
                                if rCount > 0
                                Scode3 = form.batch1.rowset.fields["Scode1"].value
                                Ingrval3 = form.batch1.rowset.fields["ingrval1"].value
                                
                                form.batch1.rowset.next()
                                rCount = rCount -1
                                endif
                                        if rCount > 0
                                        Scode4 = form.batch1.rowset.fields["Scode1"].value
                                        Ingrval4 = form.batch1.rowset.fields["ingrval1"].value
                                        
                                        form.batch1.rowset.next()
                                        rCount = rCount -1
                                        endif
                                                        if rCount > 0
                                                        Scode5 = form.batch1.rowset.fields["Scode1"].value
                                                        Ingrval5 = form.batch1.rowset.fields["ingrval1"].value
                                                        
                                                        form.batch1.rowset.next()
                                                        rCount = rCount -1
                                                        endif
                                                                if rCount > 0
                                                                Scode6 = form.batch1.rowset.fields["Scode1"].value
                                                                Ingrval6 = form.batch1.rowset.fields["ingrval1"].value
                                                                
                                                                form.batch1.rowset.next()
                                                                rCount = rCount -1
                                                                endif
                
                                                                        if rCount > 0
                                                                        Scode7 = form.batch1.rowset.fields["Scode1"].value
                                                                        Ingrval7 = form.batch1.rowset.fields["ingrval1"].value
                                                                        
                                                                        form.batch1.rowset.next()
                                                                        rCount = rCount -1
                                                                        endif
                                                                                if rCount > 0
                                                                                Scode8 = form.batch1.rowset.fields["Scode1"].value
                                                                                Ingrval8 = form.batch1.rowset.fields["ingrval1"].value
                                                                                
                                                                                form.batch1.rowset.next()
                                                                                rCount = rCount -1
                                                                                endif
                                                                                        if rCount > 0
                        Scode9 = form.batch1.rowset.fields["Scode1"].value
                   Ingrval9 = form.batch1.rowset.fields["ingrval1"].value
                        
                        form.batch1.rowset.next()
                        rCount = rCount -1
                        endif
                                if rCount > 0
                                Scode10 = form.batch1.rowset.fields["Scode1"].value
                                Ingrval10 = form.batch1.rowset.fields["ingrval1"].value
                                
                                form.batch1.rowset.next()
                                rCount = rCount -1
                                endif
                                        if rCount > 0
                                        Scode11 = form.batch1.rowset.fields["Scode1"].value
                                        Ingrval11 = form.batch1.rowset.fields["ingrval1"].value
                                        
                                        form.batch1.rowset.next()
                                        rCount = rCount -1
                                        endif
                                                        if rCount > 0
                                                        Scode12 = form.batch1.rowset.fields["Scode1"].value
                                                        Ingrval12 = form.batch1.rowset.fields["ingrval1"].value
                                                        
                                                        form.batch1.rowset.next()
                                                        rCount = rCount -1
                                                        endif
                                                                if rCount > 0
                                                                Scode13 = form.batch1.rowset.fields["Scode1"].value
                                                                Ingrval13 = form.batch1.rowset.fields["ingrval1"].value
                                                                
                                                                form.batch1.rowset.next()
                                                                rCount = rCount -1
                                                                endif
                
                                                                        if rCount > 0
                                                                        Scode14 = form.batch1.rowset.fields["Scode1"].value
                                                                        Ingrval14 = form.batch1.rowset.fields["ingrval1"].value
                                                                        
                                                                        form.batch1.rowset.next()
                                                                        rCount = rCount -1
                                                                        endif
                                                                                if rCount > 0
                                                                                Scode15 = form.batch1.rowset.fields["Scode1"].value
                                                                                Ingrval15 = form.batch1.rowset.fields["ingrval1"].value
                                                                                
                                                                                form.batch1.rowset.next()
                                                                                rCount = rCount -1
                                                                                endif
                
                 choosePrinter()
                _copies=2
                _peject="None"
                _plineno=3
                _pmargin=3
                ingnum = 3
                set printer on
        //        msgbox("Printer On")
                set margin to 10
                
                printjob
                ?        "                        " + FormName + Date()
                ?
                ?
                ? " Ingredient Amt" + " Stock Code " + " Batch Size "
                ?  
                ?
                if pCount > 0
                ?  Ingrval1 Picture "999.999" + "           " + Scode1 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval2 Picture "999.999" + "           " + Scode2 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval3 Picture "999.999" + "           " + Scode3 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval4 Picture "999.999" + "           " + Scode4 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval5 Picture "999.999" + "           " + Scode5 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval6 Picture "999.999" + "           " + Scode6 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval7 Picture "999.999" + "           " + Scode7 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval8 Picture "999.999" + "           " + Scode8 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval9 Picture "999.999" + "           " + Scode9 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval10 Picture "999.999" + "           " + Scode10 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval11 Picture "999.999" + "           " + Scode11 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval12 Picture "999.999" + "           " + Scode12 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval13 Picture "999.999" + "           " + Scode13 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval14 Picture "999.999" + "           " + Scode14 + "         " + BatchSize
                pCount = pCount - 1
                endif
                ?
                if pCount > 0
                ?  Ingrval15 Picture "999.999" + "           " + Scode15 + "         " + BatchSize
                pCount = pCount - 1
                endif
          
          _app.databases[ 1 ].emptyTable( "Batch" )
        
        // use EXCLUSIVE batch.dbf        
                
                endprintjob
                close printer
                set printer off
                
                
                
                
                //ZAP
                return