Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Thanked 0 Times in 0 Posts

    Trap Compile Errors (2000/2003)

    Is there any way to trap compile errors and have Access ignore them?

    I have included a 'Dim fd As FileDialog' command in my 2003 database, which creates a compile error when run in Access 2000. I want to insert alternate code so that if the application is run in 2000, then it will skip this compile error and run the 2000 code.

    Can I do this? I've tried setwarnings = false and on error, but the compile error keeps tripping.

    If you have any other alternatives I'd be grateful too.

    Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Trap Compile Errors (2000/2003)

    SetWarnings does not suppress compile errors, only runtime warnings.

    One workaround is to avoid the use of FileDialog, and use the GetOpenFileName API function instead - it'll work in all versions. See <post#=304810>post 304810</post#>.

    Another one is to create separate versions for Access 2002 and up on the one hand, and Access 2000 and below on the other hand. You could use conditional compilation, so that the only difference between the two versions is the value of a conditional compilation constant. Look up conditional compilation in the VBA help to see how that works.

Posting Permissions

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