Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41

    Runtime error 3001?

    Ok I know if you google this error you will get answers but to be honest those forums just make things more complicated. This code is from a form I try to open and it gives me this runtime error 3001 and when I hit debug I get what you see in the PNG attachment. I googled the dbs.openRecordset and found out that my parameters are corrected, so i'm not sure what the issue is(I am not fluent in VBA but I do know C++ and JAVA fairly well). Also I uploaded my cls file which has the full code from the Microsoft Access 2007.
    Attached Thumbnails Attached Thumbnails form.PNG  
    Attached Files Attached Files

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would use
    Code:
    Dim dbs As DAO.Database, rs As DAO.Recordset, strSQL As String
    Add a debug statement to see if the SQL string isformed correctly:
    Code:
    'counts the instances of lateness for each employee
    strSQL = "SELECT * FROM [qry_Instances_Of_Lateness] WHERE ((([qry_Instances_Of_Lateness]![Employee ID] )='" & Me.[Employee ID] & "'));"
    Debug.Print strSQL
    Set dbs = CurrentDb()
    Set a breakpoint on the "Set dbs = " line to look at the immediate window.

    Copy the SQL from the immediate window and paste into a new query. Does the query execute?

  3. #3
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    What do you mean "Copy the SQL from the immediate window and paste into a new query. Does the query execute?" I dont really understand, and wont the query that I copy an paste it into matter since the code will be different? I'm using access 2007, can you post screenshot of step by step, IF POSSIBLE?

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    The immediate window is usually visible below the code window - if not in click on view and select immediate window

    I'm sure you know what copy and paste means

    I'm sure you know what a new query is - to get to the sql window, click on the sql icon on the ribbon

    my guess is when you say this

    I googled the dbs.openRecordset and found out that my parameters are corrected
    means you have changed them to reference a form, rather than prompt you for values

    openrecordset cannot use queries with parameters. period

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Once the code reaches the breakpoint, look at the immediate window. There should be a line of SQL there.
    Copy the SQL in the immediate window.

    In the main access window (not the IDE), in the menu,
    click on CREATE.
    Click on "Query Design".
    Switch to SQL View
    Paste in the SQL copied from the immediate window into the query.

    Execute the query (press the !)
    Any errors?

  6. #6
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    @Ajax pls watch this thread cause I wont be able to post anything during the weekend, so I will get back to this thread on Monday when i am at my desk. Even tho I have a copy of the DB at home its giving tons of issues with not finding the correct path etcc.. to open query.

  7. #7
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    I did what you said reguarding the Dim dbs As DAO.Database, rs As DAO.Recordset, strSQL As String an it that fixes the error but I get another error saying the variable is not defined: The variable in question is STRSQL1
    here is image Please Help!!!!
    Click image for larger version. 

Name:	Capture.PNG 
Views:	32 
Size:	26.8 KB 
ID:	25864

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You did not Dim STRSQL1 yet, only strSQL.

  9. #9
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    So would it be STRSQL1 As String
    meaning I would put that after strSQL As String?

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Absolutely.

  11. #11
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You might have an issue with your references in VBA. Open any code module, then click Tools - References

    You wouldn't think that the order the selected references appear in the list would matter, but it does.

    There should be a reference that looks something like Microsoft Office xxxx Access database engine....

    Move that reference as far up in the list as you can, re-compile the code, and run the application again to see if that works.

  12. #12
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    What I usually do is hit the "watch this" option and it puts the code in the bottom window so i can see whats going on, but I'll try the references on Friday

  13. #13
    cloudforgiven is offline Advanced Beginner
    Windows 7 32bit Access 2003
    Join Date
    Aug 2016
    Posts
    41
    I am still having the same issue as with my OP, meaning the same Set rs=
    The changes dint really help and when I go to tools an hit references that particular option is whited out menaing I cannot click on it?/ Any ideas, since my error stays the same?

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It may be time to Compact and Repair then zip up your db and attach it to a post if you can. Remove any sensitive data of course.

  15. #15
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I am still having the same issue as with my OP, meaning the same Set rs=
    When you get that little bubble message showing in the first posted image, it's telling you that rs!cntoflate is not set. That doesn't necessarily mean the rs does not exist; it could be that the query you're referencing has no cntoflate field. To test this theory, ensure the query contains that field and is spelled correctly. If it is, try substituting the field index number, starting at 0, meaning if it's the 3rd field from left to right, it is field number 2. The conversion would be
    Me.rs.fields(2), which you could examine with a debug or message box statement right after you Set the recordset.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 08-22-2015, 11:26 AM
  2. Replies: 2
    Last Post: 10-15-2014, 04:23 AM
  3. Vb-access runtime error 3001
    By bobykuriakose12 in forum Access
    Replies: 8
    Last Post: 06-12-2013, 11:33 AM
  4. Replies: 8
    Last Post: 06-18-2012, 03:49 PM
  5. Replies: 13
    Last Post: 06-12-2012, 09:52 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