Hi ,
I created a Button w/a click event w/VB code to open a dialog box to choose a file to import into an Access Database. It works on the original Access database. Now I want to use the same code in another Access Database, & just change the Destination of the table that will be populated with the imported data. I did all that, but it won't work. I am hoping you can take a quick look at my code & tell me if I am missing anything.
Private Sub BtnSelect_Click()
Dim dlg As FileDialog ' I get a Compile Error: User-defined type not defined
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.Title = "Select the Excel file to import"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel Files", "*.xls", 1
.Filters.Add "All Files", "*.*", 2
If .Show = -1 Then
StrFileName = .SelectedItems(1)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "T_FTORN", StrFileName, True
Else
Exit Sub
End If
End With
End Sub