Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code Error in Converted Database (Access 2007)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code Error in Converted Database (Access 2007)

    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:
    <code>
    MsgBox "Insert blank diskette in your drive now.", vbOKOnly, "Insert diskette"
    If Dir("A:Temp.mdb") = "" Then ' file doesn't exist
    GoTo Continue
    Else ...</code>

  3. #3
    2 Star Lounger
    Join Date
    Oct 2004
    Location
    Minnesota, USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code Error in Converted Database (Access 2007)

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •