• Code Error in Converted Database (Access 2007)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Code Error in Converted Database (Access 2007)

    • This topic has 2 replies, 2 voices, and was last updated 17 years ago.
    Author
    Topic
    #450683

    I am converting an application from Access 2000 to 2007. Most things are converting fine, with a few tweaks. I’m pleasantly surprised. However, this piece of code gives me an error. I am feeding the code some variables, then asking it to see if a file exists in the location fed by the variables. The code errors on the With line and the message is:

    Error 2455: You entered an expression that has an invalid reference to the property FileSearch.

    With Application.FileSearch ‘looks to see if the temp.mdb already exists
    If TransferDrive = “A” Then
    MsgBox “Insert blank diskette in your drive now.”, vbOKOnly, “Instert diskette”
    .LookIn = “A:”
    .filename = “Temp.mdb”

    If .Execute = 0 Then ‘file doesn’t exist
    GoTo Continue
    Else
    MsgBox “The temp file already exists. Insert another diskette.”, vbOKOnly, “Insert New Diskette”
    GoTo ExitHere
    End If
    Else
    And so on ….

    Any ideas as to what I’m missing? I have a reference to the Microsoft Access 12.0 Object Library.

    Thanks for any suggestions.

    Nancy

    Viewing 0 reply threads
    Author
    Replies
    • #1107766

      The FileSearch object has been removed from Office 2007 VBA. Microsoft, in its infinite wisdom, has decided that this feature isn’t needed any more since people can use a desktop search engine to search for files, and hence code relying on FileSearch doesn’t work any more.

      You can use code like this instead:

      MsgBox "Insert blank diskette in your drive now.", vbOKOnly, "Insert diskette"
      If Dir("A:Temp.mdb") = "" Then ' file doesn't exist
      GoTo Continue
      Else ...

      • #1107771

        Gee, how nice of Microsoft.

        This ought to be fun, since I have variables for the drive, directory, subdirectory, etc.

        Thanks, Hans, at least I know I wasn’t going crazy!

        Nancy

    Viewing 0 reply threads
    Reply To: Code Error in Converted Database (Access 2007)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: