ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End Sub
The “Import Text Type” option group’s event procedure first checks that the selected text file is the
right type, and clears it if not, then sets up a Select Casestatement to process comma-delimited
and text files differently, calling the SaveTextFileSub:
Private Sub fraTextType_AfterUpdate()
On Error GoTo ErrorHandler
Dim strExt As String
Check that the selected text file is the right type, and clear the file selection if not.
intTextType = Nz(Me![fraTextType].Value, 1)
strTextFile = GetTextFile()
If Len(strTextFile) > 4 Then
strExt = Right(strTextFile, 3)
End If
Select Case intTextType
Case 1
Comma-delimited
If strExt = “txt” Then
SaveTextFile (“”)
Me![txtSelectedTextFile].Value = “”
End If
Case 2
Fixed-width
If strExt = “csv” Then
SaveTextFile (“”)
Me![txtSelectedTextFile].Value = “”
End If
Case 3
If strExt <> “csv” And strExt <> “txt” Then
SaveTextFile (“”)
Me![txtSelectedTextFile].Value = “”
End If
Working with External Data 10