StrataFrame Forum

BO-Count and number of records processed

http://forum.strataframe.net/Topic32174.aspx

By Thomas Holste - 8/5/2013

Hi there,

in a form I send data to wholesalers and have a property to check if the upload has worked. I call a sub-routine to process the data:



Private sub copydata(lSendenok as boolean)

BestBO1.Filter = "status = 'L'"

BestBO1.MoveFirst()

If lSendenOk Then

  ... Not yet tested

Else

   Dim nCount As Integer = 0 ' For testing

   Do

      BestBO1.STATUS = "W"

      nCount = nCount + 1  ' For testing

   Loop While BestBO1.MoveNext

   BestBO1.Save()

   MsgBox(nCount.ToString) ' For testing

Endif



At the beginning of the sub, after setting the filter-property, the bestbo1.count is 28 which are 28 records to be processed, but the Do-Loop runs only 14 times.  What may I have missed there?

Thanks in Advance

Thomas
By StrataFrame Team - 8/6/2013

You're filtering down to only those records that have a status of 'L'.  When you set the status to 'W', it removes the item from the view, so moves to the next record.  Like this:

Record1 Status L <-- Current row
Record2 Status L
Record3 Status L
Record4 Status L

Start of loop sets Record1 to Status W, and it gets filtered out:

Record2 Status L <-- Current row
Record3 Status L
Record4 Status L

Calling move next then moves to record 3, essentially skipping Record2

Record2 Status L
Record3 Status L <-- Current row
Record4 Status L

So, each time you change the status, you're changing the record and moving your pointer to the next record by removing the item from the filtered objects.  If you change your loop to Do While BestBO1.Count > 0, then, as you set the status to 'W', they will be removed from the filter, and you'll be able to get to all 28 records.
By Thomas Holste - 8/6/2013

Hi Ben,

thanks a lot, now it works fine.

Best regards

Thomas