Results 1 to 7 of 7
  1. #1
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134

    vba ms accessruntime error 3024

    Hi there,



    how can i catch this error before it happens, i.e., when OpenDatabase(DBFullName) is nothing... but I have tried with If is nothing... or if len()<= 0 then .... it doesn't work


    Code:
    Dim db as dao.Database
    Dim DBFullName as String
    
    
    DBFullName = wkmain.(Cells(30,3).Value ' ---> let's assume that the database in this path cannot be found, then what? --> I would like to check before "Set db = Opendatabase()" if is not empty.
    
    Set db = OpenDatabase(DBFullName)
    Do you have any ideas how to check before running into error 3024?

    Thanks in advance!

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you've posted to an access forum - but the reference to cells implies Excel.

    either your test would be something like


    Code:
    if not isnull(wkmain.(Cells(30,3).Value) then
        on error resume next
        set db=opendatabase(wkmain.(Cells(30,3).Value)
        if err.number<>0 then msgbox "this file has not be found - " & wkmain.(Cells(30,3).Value
        on error goto 0
    else
        msgbox "you must enter a value"
    end if
    Or I have misunderstood in which case please describe in simple English what you are trying to do

  3. #3
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Thanks Ajax...

    the issue is that wkmain.Cells(30,3).Value is always filled...

    that does not mean that the actual database is there!!!!

    When Setting the db = opendatabase() I get the error, because it is trying to opening something which is not there...

    So, how can I check before opening?

    Regards!

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    did you read my solution?

    Alternative is to use the dir function to check it exists - but that won't tell you if it is an access file

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    It appears your procedure does not include an error handler. Easier just to trap the error number.
    Code:
    Dim db as dao.Database
    Dim DBFullName as String
    
    On Error GoTo ErrHandler
    
    DBFullName = wkmain.(Cells(30,3).Value
    Set db = OpenDatabase(DBFullName)
    do stuff
    
    ExitHere:
    Set db = Nothing
    Exit Sub
    
    ErrHandler:
    If Err.Number = 3024 Then Resume ExitHere
    Else
    Msgbox .....
    Last edited by Micron; 06-29-2017 at 12:27 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    yeah is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Nov 2010
    Posts
    61
    Ever get your problem resolved?

  7. #7
    Susy is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    134
    Hi there,

    thanks for asking. I think I dit...

    Sorry that I didn't reply before... I was in a "long vacation".

    Regards!

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

Similar Threads

  1. "Could not find file <file path." - Error 3024
    By jmitchelldueck in forum Access
    Replies: 4
    Last Post: 07-30-2015, 02:15 PM
  2. Run Time Error 3024
    By dccjr in forum Programming
    Replies: 9
    Last Post: 05-01-2013, 09:11 PM
  3. Replies: 1
    Last Post: 04-30-2013, 05:44 PM
  4. Replies: 0
    Last Post: 07-16-2012, 05:42 AM
  5. Error 3024 At Start UP
    By Damonpc in forum Access
    Replies: 10
    Last Post: 11-26-2010, 07:40 PM

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