Results 1 to 5 of 5
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question Error Handling

    Can you use multiple "On Error Go To" within the same Sub? What I would like to do is check for an export error on a couple different exports that occur in the same event.



    i.e.

    If Export1 fails due to file already being there I want to rename my export file "FileExport1_1" instead of "FileExport1"

    If Export2 fails due to file already being there I wan to do the same thing, but it would be a different file name ("FileExport2_1" as opposed to "FileExport2").

    There may be a different way to accomplish what I want to do, and if so I am all ears.

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    just check file existance then export

    Dim fso
    Set fso = CreateObject("Scripting.FileSystemObject")

    If Not fso.FileExists(fileNameWithPath) Then
    export to file1
    else
    export to file2
    end if

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    in addition to weekend's solution, did you know you can use the DIR() function to check a file's existence? The LEN function will return '0' if the file path name does not exist:
    Code:
    LEN(dir("c:\myNonExistentFileName.txt"))
    The answer will be 0 in this case.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Quote Originally Posted by ajetrumpet View Post
    in addition to weekend's solution, did you know you can use the DIR() function to check a file's existence? The LEN function will return '0' if the file path name does not exist:
    Code:
    LEN(dir("c:\myNonExistentFileName.txt"))
    The answer will be 0 in this case.
    WOW! I never know that. it's much more simple.

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Great tips from both. Thanks a lot!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error Handling
    By trb5016 in forum Access
    Replies: 2
    Last Post: 08-10-2010, 08:37 AM
  2. #error handling
    By mws5872 in forum Access
    Replies: 4
    Last Post: 05-12-2010, 07:06 AM
  3. Error Handling for newbie
    By smikkelsen in forum Access
    Replies: 4
    Last Post: 04-08-2010, 05:17 PM
  4. Handling dates in queries
    By mrk68 in forum Access
    Replies: 4
    Last Post: 03-23-2009, 06:35 AM
  5. Replies: 0
    Last Post: 03-05-2009, 12:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums