Error Handling 53/New file

How would I handle error "53"...... i MOVED MY FILE FROM THE HARD CODED PATH location just TO SEE IF I CAN GET ERROR HANDLING. I get error 53 upon form load. I should be able to create the file if it does not exist. please advise.

Thanks

private Sub Form_Load()

mintFileNumber = FreeFile

'Open mstrFileName for input as #1

Open "c:\temp\phones.dat" for input as #mintFileNumber

Do Until EOF(mintFileNumber)
input #1, strPerson.FirstName, strPerson.LastName, strPerson.Phone
With lstContactName
.AddItem Trim(strPerson.FirstName) & ", " _
& Trim(strPerson.LastName) & ", " & _
Trim(strPerson.Phone)
End With
Loop

Close #1

Form_load_Exit:
Exit Sub
HandleErors:
Dim intResponse as Integer
Select Case Err.Number
Case 53, 76
intResponse = MsgBox("Create a new File?", _
vbYesNo + vbQuestion, "File not Found")
If intResponse = vbYes then
resume Form_load_Exit
else
mnuFileExit_Click
End If

Case 71
intResponse = MsgBox("Disk not ready Retry", _
vbRetryCancel + vbQuestion, "Disk error")
If intResponse = vbRetry then
resume
else
mnuFileExit_Click
End If

Case else
Err.Raise Err
End Select
resume

End Sub
[1571 byte] By [ikiani] at [2007-11-15 18:34:54]
# 1 Re: Error Handling 53/New file
Dim FileName as string
'...
'Add the following to your error handling section before exiting the form load.
If intResponse = vbYes then
FileName = InputBox("Enter file full path:", "File Name")
Open FileName for Output as #1
Close #1
resume Form_load_Exit
End If

Help us improve our answers by rating them.
MKSa at 2007-11-10 0:33:39 >