FindDialog reference is missing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lynnchester
    New Member
    • Sep 2007
    • 6

    FindDialog reference is missing

    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??
  • cyberdwarf
    Recognized Expert New Member
    • Nov 2006
    • 218

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

    HTH

    Steve

    Comment

    • Jim Doherty
      Recognized Expert Contributor
      • Aug 2007
      • 897

      #3
      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...REFEREN CES ensure that the library is selected and ticked in the list.


      Regards

      Jim :)

      Comment

      • lynnchester
        New Member
        • Sep 2007
        • 6

        #4
        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...

        Comment

        • Jim Doherty
          Recognized Expert Contributor
          • Aug 2007
          • 897

          #5
          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 :)

          Comment

          • lynnchester
            New Member
            • Sep 2007
            • 6

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

            Code:
            Private Sub cmdImportJobs_Click()
            
                '---------------------------------------------------------
                'Declare a variable as a FileDialog object.
                '---------------------------------------------------------
                Dim fd As FileDialog
            
                '---------------------------------------------------------
                ' Create a FileDialog object as a File Picker dialog box.
                '---------------------------------------------------------
                Set fd = Application.FileDialog(msoFileDialogFilePicker)
            
            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

            Comment

            • Jim Doherty
              Recognized Expert Contributor
              • Aug 2007
              • 897

              #7
              Originally posted by lynnchester
              I've tested the code just with the one line in it and it still errors:

              Code:
              Private Sub cmdImportJobs_Click()
               
              '---------------------------------------------------------
              'Declare a variable as a FileDialog object.
              '---------------------------------------------------------
              Dim fd As FileDialog
               
              '---------------------------------------------------------
              ' Create a FileDialog object as a File Picker dialog box.
              '---------------------------------------------------------
              Set fd = Application.FileDialog(msoFileDialogFilePicker)
               
              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

              Comment

              • lynnchester
                New Member
                • Sep 2007
                • 6

                #8
                You darling! Thanks Jim.

                Comment

                • Jim Doherty
                  Recognized Expert Contributor
                  • Aug 2007
                  • 897

                  #9
                  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 :)

                  Comment

                  Working...