Results 1 to 2 of 2
  1. #1
    faromic is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    1

    Randomly occuring unspecified error with VBA and ACCESS

    I am currently working on a module (actually, is basically complete) that loops through several databases (the actual number depends) and performs several queries on the databases. Then a couple more queries are performed on the first set of queries. I get a random error at the same point in the code but at different points in the loop. Additionally, it doesn't occur every time the code is run. It happens a good amount of the time but sometimes it will run all the way through without any problems. The error is"

    Run-time error '-2147467259 (80004005)':
    Unspecified Error

    I have searched the internet for days on this error and am having problems finding a solution. It may have something to do with versions of libraries or something, but I'm very new to this and have absolutely no idea.

    Here is the code:




    Code:
    Sub queryTableForStatic_C2XX(dbpath) 'check
    Dim cn As ADODB.Connection
    Dim cat As New ADOX.Catalog
    Dim cmd As New ADODB.Command
    Dim sSQL As String
    
    Set cn = New ADODB.Connection
        
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbpath  <---------ERROR!!!
    
        sSQL = "SELECT CDbl([Static_Forces].[Area]) AS Area, IIf(Right([OutputCase],5)='_Th A',Mid([Outputcase],1,Len([OutputCase])-5),"
        sSQL = sSQL & "IIf(Right([OutputCase],5)='_Th G',Mid([Outputcase],1,Len([OutputCase])-5),[OutputCase])) AS Combos, CDbl(Static_Forces.Joint) as Joint, "
        sSQL = sSQL & "Static_Forces.F11, Static_Forces.F22, Static_Forces.F12, Static_Forces.M11, Static_Forces.M22, Static_Forces.M12, Static_Forces.V13, "
        sSQL = sSQL & "Static_Forces.V23, IIf(Right([OutputCase],5)='_Th A',Right([OutputCase],5),IIf(Right([OutputCase],5)='_Th G',Right([OutputCase],5))) AS TH "
        sSQL = sSQL & "FROM Static_Forces "
        sSQL = sSQL & "WHERE (((IIf(Right([OutputCase],5)='_Th A',Mid([Outputcase],1,Len([OutputCase])-5),IIf(Right([OutputCase],5)='_Th G',Mid([Outputcase],1,"
        sSQL = sSQL & "Len([OutputCase])-5),[OutputCase]))) Like 'C*') AND ((CDbl(IIf(Right(Mid([Static_Forces].[OutputCase],2,14),5) Like '_Th*',(Mid([Static_Forces]."
        sSQL = sSQL & "[OutputCase],2,Len([Static_Forces].[OutputCase])-6)),(Mid([Static_Forces].[OutputCase],2,Len([Static_Forces].[OutputCase])-1)))))>=2000 And "
        sSQL = sSQL & "(CDbl(IIf(Right(Mid([Static_Forces].[OutputCase],2,14),5) Like '_Th*',(Mid([Static_Forces].[OutputCase],2,Len([Static_Forces].[OutputCase])-6)),"
        sSQL = sSQL & "(Mid([Static_Forces].[OutputCase],2,Len([Static_Forces].[OutputCase])-1)))))<=2999));"
        
        Set cat = New ADOX.Catalog
        Set cmd = New ADODB.Command
        
        cat.ActiveConnection = cn
        cmd.CommandText = sSQL
        cat.Views.Append "Static_C2XX", cmd
        
        Set cat = Nothing
        Set cmd = Nothing
        cn.Close
        Set cn = Nothing
        
    End Sub

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    If you do a debug on that line and hover over "dbpath" at the end of the line what data does it say it contains?

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

Similar Threads

  1. Access to SQL error
    By dalet in forum Programming
    Replies: 5
    Last Post: 10-16-2009, 07:43 AM
  2. [Error]Access Crashed Issues
    By ckhaos in forum Security
    Replies: 1
    Last Post: 06-23-2009, 02:08 PM
  3. Error excel refresh from access
    By goyal in forum Access
    Replies: 0
    Last Post: 06-10-2009, 10:59 AM
  4. Replies: 0
    Last Post: 05-14-2009, 12:34 AM
  5. Replies: 0
    Last Post: 06-19-2007, 09:45 AM

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