Connecting Tech Pros Worldwide Forums | Help | Site Map

FindDialog reference is missing

Newbie
 
Join Date: Sep 2007
Posts: 6
#1: Sep 24 '07
I would like to display a file dialog using vba, so that the user can select a file and path. I copied and pasted the MS example to test, but can't get past the declaration; I get an error saying "Compile error: User defined type not defined" and the text "fd as FileDialog" in my declaration is highlighted. This says to me that I'm missing a reference - but which one??

Expert
 
Join Date: Nov 2006
Location: Andover, Hants, UK
Posts: 215
#2: Sep 24 '07

re: FindDialog reference is missing


You will need to make an additional reference to the Microsoft Office 10 (or 11, etc) Object Library.

HTH

Steve
Jim Doherty's Avatar
Moderator
 
Join Date: Aug 2007
Location: Derbyshire,England
Posts: 639
#3: Sep 24 '07

re: FindDialog reference is missing


Quote:

Originally Posted by lynnchester

I would like to display a file dialog using vba, so that the user can select a file and path. I copied and pasted the MS example to test, but can't get past the declaration; I get an error saying "Compile error: User defined type not defined" and the text "fd as FileDialog" in my declaration is highlighted. This says to me that I'm missing a reference - but which one??

Which version of Access are you using please? for instance if it is ACC 2002 then Microsoft Office 10.0 Object Library If it is ACC 2003 then Microsoft Office 11.0 Object Library.

Please note various functionality is always going to be version dependant. For instance if you were using Access version 1 or 2 then this functionality would not be available and you would be calling on the windows application programming interface (API) to achieve the same thing. It is only with progressive development and later versions that hitherto complex modules are reduced to single commands like..............FileDialog

So as mentioned in para 1 if you are using ACC 2003 then go into the VBA module TOOLS...REFERENCES ensure that the library is selected and ticked in the list.


Regards

Jim :)
Newbie
 
Join Date: Sep 2007
Posts: 6
#4: Nov 7 '07

re: FindDialog reference is missing


Thanks for the help - it seemed to work, but then I updated my database to 2003 (I've been using Access 2003 but the database itself was in 2000 format) and now it's no longer working - I'm getting the original problem again.
I'm not 100% sure the upgrade is what caused it, as I haven't tested the FileDialog function for some time - just started working on it again today after a few weeks. MS Access 11.0 Object Library is definitely selected in References...
Jim Doherty's Avatar
Moderator
 
Join Date: Aug 2007
Location: Derbyshire,England
Posts: 639
#5: Nov 7 '07

re: FindDialog reference is missing


Quote:

Originally Posted by lynnchester

Thanks for the help - it seemed to work, but then I updated my database to 2003 (I've been using Access 2003 but the database itself was in 2000 format) and now it's no longer working - I'm getting the original problem again.
I'm not 100% sure the upgrade is what caused it, as I haven't tested the FileDialog function for some time - just started working on it again today after a few weeks. MS Access 11.0 Object Library is definitely selected in References...

Post the offending module code (please remember to use code tags) so that contributors can see what code you originally pasted into your database and also list the references (in the order that you have them in the list)

Regards

Jim :)
Newbie
 
Join Date: Sep 2007
Posts: 6
#6: Nov 7 '07

re: FindDialog reference is missing


I've tested the code just with the one line in it and it still errors:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdImportJobs_Click()
  2.  
  3.     '---------------------------------------------------------
  4.     'Declare a variable as a FileDialog object.
  5.     '---------------------------------------------------------
  6.     Dim fd As FileDialog
  7.  
  8.     '---------------------------------------------------------
  9.     ' Create a FileDialog object as a File Picker dialog box.
  10.     '---------------------------------------------------------
  11.     Set fd = Application.FileDialog(msoFileDialogFilePicker)
  12.  
  13. End Sub
I have the following references:
Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.5 Library
Jim Doherty's Avatar
Moderator
 
Join Date: Aug 2007
Location: Derbyshire,England
Posts: 639
#7: Nov 7 '07

re: FindDialog reference is missing


Quote:

Originally Posted by lynnchester

I've tested the code just with the one line in it and it still errors:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdImportJobs_Click()
  2.  
  3. '---------------------------------------------------------
  4. 'Declare a variable as a FileDialog object.
  5. '---------------------------------------------------------
  6. Dim fd As FileDialog
  7.  
  8. '---------------------------------------------------------
  9. ' Create a FileDialog object as a File Picker dialog box.
  10. '---------------------------------------------------------
  11. Set fd = Application.FileDialog(msoFileDialogFilePicker)
  12.  
  13. End Sub
I have the following references:
Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.5 Library


Check that you not only have the MS Access 11.0 object library but you also have the MS Office 11.0 object library.

Jim
Newbie
 
Join Date: Sep 2007
Posts: 6
#8: Nov 8 '07

re: FindDialog reference is missing


You darling! Thanks Jim.
Jim Doherty's Avatar
Moderator
 
Join Date: Aug 2007
Location: Derbyshire,England
Posts: 639
#9: Nov 8 '07

re: FindDialog reference is missing


Quote:

Originally Posted by lynnchester

You darling! Thanks Jim.

hahah long time since I was called that on any forum ...glad it worked out for you :))

Jim :)
Reply