Can someone please explain to me two things from the code below and how to fix the problems?
#1 Why would the If statement never be executed?
#2 Why no code past the Loop Statement is executed?
The Problem is that I open this file again later in the program for output, and I get an error that the file is already open. I have tried everything I can think of.
Private Sub Form_Load()
Dim BLNEOF As Boolean
On Error GoTo HandleErrors
BLNEOF = False
Open GSTRFilePath For Input As #1
Do
Input #1, GSTRInspectorName, GSTRInspectorNumber
CBOInspectorName.AddItem GSTRInspectorName
CBOInspectorName.ItemData(CBOInspectorName.NewIndex) = GSTRInspectorNumber
MsgBox "Not Closed", vbOKOnly, "NOT CLOSED" 'Trubleshooting Purposes
If EOF(1) = True Then
BLNEOF = True
MsgBox "Closed", vbOKOnly, "CLOSED" 'Trubleshooting Purposes
End If
Loop While BLNEOF = False
MsgBox "Closed", vbOKOnly, "CLOSED" 'Trubleshooting Purposes
Close
Form_Load_Exit:
Exit Sub
HandleErrors:
Select Case Err.Number
Case 53, 76 'File or path not found
Resume Form_Load_Exit 'Exit the procedure
Case 71 'Disk not ready
GINTResponse = MsgBox("Disk not ready. Retry?", _
vbRetryCancel + vbQuestion, "Disk Error"
If GINTResponse = vbRetry Then
Resume 'Try again
Else
End 'Exit Program
End If
'Case Else 'All other errors should cancel execution
' Err.Raise Err
End Select
End Sub
#1 Why would the If statement never be executed?
#2 Why no code past the Loop Statement is executed?
The Problem is that I open this file again later in the program for output, and I get an error that the file is already open. I have tried everything I can think of.
Private Sub Form_Load()
Dim BLNEOF As Boolean
On Error GoTo HandleErrors
BLNEOF = False
Open GSTRFilePath For Input As #1
Do
Input #1, GSTRInspectorName, GSTRInspectorNumber
CBOInspectorName.AddItem GSTRInspectorName
CBOInspectorName.ItemData(CBOInspectorName.NewIndex) = GSTRInspectorNumber
MsgBox "Not Closed", vbOKOnly, "NOT CLOSED" 'Trubleshooting Purposes
If EOF(1) = True Then
BLNEOF = True
MsgBox "Closed", vbOKOnly, "CLOSED" 'Trubleshooting Purposes
End If
Loop While BLNEOF = False
MsgBox "Closed", vbOKOnly, "CLOSED" 'Trubleshooting Purposes
Close
Form_Load_Exit:
Exit Sub
HandleErrors:
Select Case Err.Number
Case 53, 76 'File or path not found
Resume Form_Load_Exit 'Exit the procedure
Case 71 'Disk not ready
GINTResponse = MsgBox("Disk not ready. Retry?", _
vbRetryCancel + vbQuestion, "Disk Error"
If GINTResponse = vbRetry Then
Resume 'Try again
Else
End 'Exit Program
End If
'Case Else 'All other errors should cancel execution
' Err.Raise Err
End Select
End Sub