Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    22

    Unanswered: While Loop Error

    The following While Loop is producing an error in the nested While Loop when it reaches EOF. Can anyone help me determine why? The error is Run-Time Error 3021: Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    Code:
    While Not SummaryRS.EOF And Not CancelPrintout
                I = I + 2
                CFtemp = ""
                If IsNull(SummaryRS!CountyFiled) Then
                    .Cells(I, 2) = "NULL"
                Else
                    CFtemp = SummaryRS!CountyFiled
                    .Cells(I, 2) = SummaryRS!CountyFiled
                End If
                CFcount = 0
                While CFtemp = SummaryRS!CountyFiled _
                    Or IsNull(SummaryRS!CountyFiled) _
                    And Not SummaryRS.EOF
                        CFcount = CFcount + 1
                        SummaryRS.MoveNext
                Wend
                .Cells(I, 4) = CFcount
                DoEvents
            Wend

  2. #2
    Join Date
    Nov 2004
    Posts
    108

    Try or instead of and

    Code:
    While Not SummaryRS.EOF [S]And[/S] Or Not CancelPrintout
    to err is human ; to really mess things up requires a computer

  3. #3
    Join Date
    Nov 2004
    Posts
    108
    Code:
    While Not SummaryRS.EOF [S]And Not CancelPrintout[/S] 
         If cancelPrintout then exit Do
    .
    .
    .
    to err is human ; to really mess things up requires a computer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •