M
mikeburg
The following VBA error traping code works great once. However, need
additional VBA code to make it work repeatedly if the file specified is
not found. For example entering 0128 for 0158 then 0185 for 0158 causes
an File not Found Eorror #53.
Sub Auto_open()
Dim strClientNumber As String
Dim dtFileDate As Date
On Error GoTo ErrorTrap
strClientNumber = Application.InputBox("Enter A/R Client Number
(ex: 0158): ")
If strClientNumber = "" Then GoTo Done
If strClientNumber = False Then GoTo Done
dtFileDate = Int(FileDateTime("C:\USR\MIKE\AT" & strClientNumber &
".MB"))
ErrorTrap:
If Err.Number <> 0 Then
strClientNumber = _
Application.InputBox("Your file does not exist!" _
& vbCrLf & vbCrLf & "Enter A/R Client Number (ex: 0158): ")
If strClientNumber = "" Then GoTo Done
If strClientNumber = False Then GoTo Done
dtFileDate = Int(FileDateTime("C:\USR\MIKE\AT" _
& strClientNumber & ".MB"))
End If
'More code exists here to import the above file that is found
End Sub
Any & all help is very much appreciated. However, since I am still
learning, please keep the VBA code simple. Thank you, mikeburg
additional VBA code to make it work repeatedly if the file specified is
not found. For example entering 0128 for 0158 then 0185 for 0158 causes
an File not Found Eorror #53.
Sub Auto_open()
Dim strClientNumber As String
Dim dtFileDate As Date
On Error GoTo ErrorTrap
strClientNumber = Application.InputBox("Enter A/R Client Number
(ex: 0158): ")
If strClientNumber = "" Then GoTo Done
If strClientNumber = False Then GoTo Done
dtFileDate = Int(FileDateTime("C:\USR\MIKE\AT" & strClientNumber &
".MB"))
ErrorTrap:
If Err.Number <> 0 Then
strClientNumber = _
Application.InputBox("Your file does not exist!" _
& vbCrLf & vbCrLf & "Enter A/R Client Number (ex: 0158): ")
If strClientNumber = "" Then GoTo Done
If strClientNumber = False Then GoTo Done
dtFileDate = Int(FileDateTime("C:\USR\MIKE\AT" _
& strClientNumber & ".MB"))
End If
'More code exists here to import the above file that is found
End Sub
Any & all help is very much appreciated. However, since I am still
learning, please keep the VBA code simple. Thank you, mikeburg