Results 1 to 2 of 2

Fixing run-time error 3049

  1. #1
    kthakk4 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    1

    Fixing run-time error 3049

    I have some code that was working fine, but recently I started getting VBA Runtime Error 3049 - The error message indicates: "Cannot open database ''. It may not be a database that your application recognizes, or the file may be corrupt."

    Following is the code for function:

    Function MakeListingTable()
    Dim db As DAO.Database, rs As DAO.Recordset, runcode As String, qd As DAO.QueryDef
    Set db = CurrentDb
    DoEvents
    runcode = Wait(3, 1)
    Set rs = db.OpenRecordset("Y_Distinct_Levels")
    While Not rs.EOF
    Select Case rs("LEVEL_ID_TYPE")
    Case "terr"
    'Append in terr and account
    Set qd = db.QueryDefs("Y03_Append_Y_Final_Listing")
    qd("Load_Report_Name") = rs("Report_Name")
    qd("Load_nat") = "*"
    qd("Load_reg") = "*"
    qd("Load_dist") = "*"
    qd("Load_terr") = rs("level_id")
    qd.Execute dbFailOnError

    Case "dist"
    'Append in dist, terr and account
    Set qd = db.QueryDefs("Y03_Append_Y_Final_Listing")
    qd("Load_Report_Name") = rs("Report_Name")
    qd("Load_nat") = "*"
    qd("Load_reg") = "*"
    qd("Load_dist") = rs("level_id")
    qd("Load_terr") = "*"
    qd.Execute dbFailOnError

    Case "reg"
    'Append in reg, dist, terr and account
    Set qd = db.QueryDefs("Y03_Append_Y_Final_Listing")
    qd("Load_Report_Name") = rs("Report_Name")
    qd("Load_nat") = "*"
    qd("Load_reg") = rs("level_id")
    qd("Load_dist") = "*"
    qd("Load_terr") = "*"
    qd.Execute dbFailOnError

    Case "nat"
    'Append in nat, reg, dist, terr and account
    Set qd = db.QueryDefs("Y03_Append_Y_Final_Listing")
    qd("Load_Report_Name") = rs("Report_Name")
    qd("Load_nat") = rs("level_id")
    qd("Load_reg") = "*"
    qd("Load_dist") = "*"
    qd("Load_terr") = "*"
    qd.Execute dbFailOnError

    End Select
    rs.MoveNext
    Wend
    End Function


    Here "Y03_Append_Y_Final_Listing is a query that updates a table. The debugger for this error appears on the red colored text in code.

    I have already used the compact and repair tool on the database. Additionally, I have exported contents of the database into a new blank access file in order to rule out data corruption.

    What I find weird is that this error happens only on some occasions and seem to be related to the number or records being appended.

  2. #2
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,696
    I've never used this method that you're using. however, are you sure the prob is the num of recs being appended? does it break on any other case?

    one 'technical' thing to fix is to put your decs on single lines only:

    Code:
    Dim db As DAO.Database
    dim rs As DAO.Recordset, runcode As String
    dim qd As DAO.QueryDef
    believe it or not, I've seen this cause problems, and I believe the last problem I saw was with the currentdb!

    the other thing to consider here is that you're requesting a lot of memory usage from access by doing this. this is asking the engine to do a lot of work very quickly (assuming some requests are using high amounts of recs)

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

Similar Threads

  1. Fixing Reference problem
    By Alex Motilal in forum Access
    Replies: 6
    Last Post: 12-30-2010, 12:12 AM
  2. Replies: 2
    Last Post: 12-23-2010, 07:11 AM
  3. Replies: 2
    Last Post: 12-02-2010, 12:35 AM
  4. Help Needed Fixing User ID
    By aamer in forum Access
    Replies: 1
    Last Post: 10-29-2010, 06:27 PM
  5. need a little help fixing an SQL error...
    By markjkubicki in forum Queries
    Replies: 3
    Last Post: 08-04-2010, 05:15 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
  •  
Tech Forums: Microsoft Office Forums