Source language: Translate to:

check if list has a no?

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

check if list has a no?

Postby yanzco » Thu Sep 04, 2014 7:30 am

hello..

i have a table..
every item, it adds a yes or no..

i need a checker if the table has a single no in it..

i made this subroutine called OUTchecker
it checks if all items are out.. or not..

but it seems this code of mine, is only able to check the last item..
i need it to check every field so i can determine if it is complete or in progress..


Code: Select all
dbpQuery "Hexdb" "SOD" "InvoiceNumber = [#34][VTInvoiceNumber][#34]"
SetVar "[translistcount]" "[Hexdb.SOD.$RecCount]"
dbpFirst "Hexdb" "SOD"
Loop "1" "[translistcount]" "[looper]"
If "[Hexdb.SOD.out]" "=" "[Hexdb.SOD.Quantity]"
SetVar "[CompleteOUT]" "YES"
dbpNext "Hexdb" "SOD"
Else
SetVar "[CompleteOUT]" "NO"
dbpNext "Hexdb" "SOD"
EndIf
EndLoop

If "[CompleteOUT]" "=" "YES"
SetVar "[VtsStatus]" "Complete"
SetVar "[Hexdb.Sales.sStatus]" "Complete"
dbpSaveEdits "Hexdb" "Sales"
Else
If "[CompleteOUT]" "=" "NO"
SetVar "[VtsStatus]" "In Progress"
SetVar "[Hexdb.Sales.sStatus]" "In Progress"
dbpSaveEdits "Hexdb" "Sales"
Else
Endif
EndIf
Return
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: check if list has a no?

Postby Gaev » Thu Sep 04, 2014 8:06 am

yanzco:

Since you are updating [CompleteOUT] for each record, the value from each successive record over-writes the value from the previous record.

Try this code ...
Code: Select all
dbpQuery "Hexdb" "SOD" "InvoiceNumber = [#34][VTInvoiceNumber][#34]"
SetVar "[translistcount]" "[Hexdb.SOD.$RecCount]"
dbpFirst "Hexdb" "SOD"

SetVar "[CompleteOUT]" "YES"

Loop "1" "[translistcount]" "[looper]"
   If "[Hexdb.SOD.out]" "=" "[Hexdb.SOD.Quantity]"
      dbpNext "Hexdb" "SOD"
   Else
      SetVar "[CompleteOUT]" "NO"
      dbpNext "Hexdb" "SOD"
   EndIf
EndLoop


So it starts out with a value of "YES" ... and only changes to "NO" when one of the records with a mismatch is found.

Also, if you are only interested to know if "there is at least one mismatch" ... you can use ExitLoop like this ...
Code: Select all
dbpQuery "Hexdb" "SOD" "InvoiceNumber = [#34][VTInvoiceNumber][#34]"
SetVar "[translistcount]" "[Hexdb.SOD.$RecCount]"
dbpFirst "Hexdb" "SOD"

SetVar "[CompleteOUT]" "YES"

Loop "1" "[translistcount]" "[looper]"
   If "[Hexdb.SOD.out]" "=" "[Hexdb.SOD.Quantity]"
      dbpNext "Hexdb" "SOD"
   Else
      SetVar "[CompleteOUT]" "NO"
      ExitLoop
   EndIf
EndLoop


Finally, you can do all this directly within the dbpQuery command like this ...
Code: Select all
dbpQuery "Hexdb" "SOD" "InvoiceNumber = [#34][VTInvoiceNumber][#34] AND out <> Quantity"
If "[Hexdb.SOD.$RecCount]" "=" "0"
   ... no mismatches
Else
   ... one or more mismatches

EndIf
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: check if list has a no?

Postby mishem » Thu Sep 04, 2014 8:14 am

Especially not penetrate, but from the provided code can see that.

Code: Select all
dbpQuery "Hexdb" "SOD" "InvoiceNumber = [#34][VTInvoiceNumber][#34]"
     SetVar "[translistcount]" "[Hexdb.SOD.$RecCount]"
     dbpFirst "Hexdb" "SOD"
    Loop "1" "[translistcount]" "[looper]"
       If "[Hexdb.SOD.out]" "=" "[Hexdb.SOD.Quantity]"
           SetVar "[CompleteOUT]" "YES"
           SetVar "[VtsStatus]" "Complete"
           SetVar "[Hexdb.Sales.sStatus]" "Complete"
         Else
            SetVar "[CompleteOUT]" "NO"
            SetVar "[VtsStatus]" "In Progress"
            SetVar "[Hexdb.Sales.sStatus]" "In Progress"
       EndIf
       dbpSaveEdits "Hexdb" "Sales"
       dbpAddRecord "Hexdb" "Sales"
       dbpNext "Hexdb" "SOD"
    EndLoop
Return
mishem
 
Posts: 574
Joined: Mon Oct 08, 2012 1:51 pm

Re: check if list has a no?

Postby yanzco » Thu Sep 04, 2014 6:59 pm

thanks gaev! that worked.. didnt know it was that easy.. :lol:
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 3 guests