C
cameron
Hi,
Our client has an Access 2000 file format mdb file which I am working on. I have Access 2002 on my machine.
I found this Open FIle Dialog function that works perfectly fine when I tried it on the Northwind.mdb (also Access 2000 file format). However when I copy this function into the client's file and tried to execute it, I get this error "Compile error: User-defined type not defined" and this line code is highlighted "...fDialog As Office.FileDialog"
I have verified in Tools/References/Microsoft Access 10.0 Object Library is selected. I have to create a form with the Open FIle Dialog to allow a user to pick a *.mdb file and then the code will do a Open DB on this *.mdb file, read in records from one of the tables and append the new records to a current table.
Does anyone know what is causing the error ?
Private Sub cmdFileDialog_Click()
'Requires reference to Microsoft Office 10.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please select the .mdb file to import data from"
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
If .Show = True Then
For Each varFile In .SelectedItems
Me.txtFileToOpen = varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
Our client has an Access 2000 file format mdb file which I am working on. I have Access 2002 on my machine.
I found this Open FIle Dialog function that works perfectly fine when I tried it on the Northwind.mdb (also Access 2000 file format). However when I copy this function into the client's file and tried to execute it, I get this error "Compile error: User-defined type not defined" and this line code is highlighted "...fDialog As Office.FileDialog"
I have verified in Tools/References/Microsoft Access 10.0 Object Library is selected. I have to create a form with the Open FIle Dialog to allow a user to pick a *.mdb file and then the code will do a Open DB on this *.mdb file, read in records from one of the tables and append the new records to a current table.
Does anyone know what is causing the error ?
Private Sub cmdFileDialog_Click()
'Requires reference to Microsoft Office 10.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please select the .mdb file to import data from"
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
If .Show = True Then
For Each varFile In .SelectedItems
Me.txtFileToOpen = varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub