Access.2007.VBA.Bibl..

(John Hannent) #1
strTitle = “Jobs imported”
strPrompt = “New jobs imported into tblJobs from “ _
& GetAppFile()
MsgBox strPrompt, vbInformation + vbOKOnly, strTitle

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit

End Sub

The Source File button’s event procedure opens a File Picker dialog for selecting an application file for
importing, filtering for dBASE, Paradox, or Lotus files depending on the option selected on the form:


Private Sub cmdSourceFile_Click()

On Error GoTo ErrorHandler

Dim fd As Office.FileDialog
Dim txt As Access.TextBox
Dim strPath As String
Dim strFilter As String

Create a FileDialogobject as a File Picker dialog box.


Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set txt = Me![txtSelectedAppFile]

Set the initial path to the custom Input Documents path


strPath = GetInputDocsPath()
intFileType = Nz(Me![fraFileType].Value, 1)

With fd
.title = “Select database or spreadsheet file with “ _
& “job data to import”
.ButtonName = “Select”
.Filters.Clear

Select Case intFileType

Case 1
.Filters.Add “dBASE files”, “*.dbf”

Working with External Data 10

Free download pdf