I'm having trouble using the BOF function in a DO LOOP. [DirectPlate-BathChgCleaner] is a checkbox. I'm trying to loop through the recordset in order to determine the [DirectPlate-TotalSurfaceSqFt] value when the
[DirectPlate-BathChgCleaner] checkbox is True. This works fine except for when there is no True value for
[DirectPlate-BathChgCleaner] in the recordset.
I've included a BOF condition in my DO LOOP, but for some reason I get the "no current record" error when there is no record that meets the condition [DirectPlate-BathChgCleaner]=True. The error occurs on the "Do Until" line of my code. I'm trying to write this part of the code so I don't get errors when I first start using this database.
Any help would be greatly appreciated!
[DirectPlate-BathChgCleaner] checkbox is True. This works fine except for when there is no True value for
[DirectPlate-BathChgCleaner] in the recordset.
I've included a BOF condition in my DO LOOP, but for some reason I get the "no current record" error when there is no record that meets the condition [DirectPlate-BathChgCleaner]=True. The error occurs on the "Do Until" line of my code. I'm trying to write this part of the code so I don't get errors when I first start using this database.
Any help would be greatly appreciated!
Code:
Set db = CurrentDb()
Set rs = db.OpenRecordset("select [DirectPlate-Date/Time]," & _
"[DirectPlate-TotalSurfaceSqFt]," & _
"[DirectPlate-BathChgCleaner]," & _
" from [Direct Plate PM Log]" & _
" order by [DirectPlate-Date/Time]")
''''''DETERMINE TOTAL SQ FT
CurrentTotalSqFt = _
DSum("[DirectPlate-DJSurfaceSqFt]", "[Direct Plate Production Log]")
''''DETERMINE TOTAL SQUARE FEET
''''SINCE CLEANER BATH CHANGE
rs.MoveLast
Do Until rs![DirectPlate-BathChgCleaner] = True Or rs.BOF = True
rs.MovePrevious
Loop
If Not rs.BOF = True Then
Me.lblCleanerBathChg.Caption = _
FormatNumber(CurrentTotalSqFt - rs![DirectPlate-TotalSurfaceSqFt], 0)
Else
Me.lblCleanerBathChg.Caption = "N/A"
End If