Solved

error 3001 when opening recordset

Posted on 2004-09-07
9
228 Views
Last Modified: 2010-04-08
Hi, i'm getting an error 3001 - Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
in the line indicated below. Can anyone help please - I'm really fed up with this!  The database in question is Access.

                Dim objADOConn
      Dim objInspector
      Dim rstLight_Audits

      'connect to database
          Set objADOConn = CreateObject("ADODB.Connection")
          objADOConn.Open "DSN=Light_Audit_db"
          
      Set rstLight_Audits = CreateObject("ADODB.Recordset")
      
      rstLight_Audits.Open "Light_Audits", objADOConn, adOpenDynamic, adLockOptimistic, adCmdTable  'Error here.
      
0
Comment
Question by:colinspurs
  • 6
  • 3
9 Comments
 
LVL 15

Expert Comment

by:will_scarlet7
Comment Utility
Could be that you need an SQL string in your recordset open statement. Something like this perhaps:

rstLight_Audits.Open "SELECT * FROM Light_Audits;", objADOConn, adOpenDynamic, adLockOptimistic, adCmdTable  'Error here.
0
 
LVL 3

Author Comment

by:colinspurs
Comment Utility
Nope - tried it and got same error (removed adCmdTable also).

0
 
LVL 15

Expert Comment

by:will_scarlet7
Comment Utility
Question: What is the name of the table/query that you are trying to connect to?
0
 
LVL 15

Expert Comment

by:will_scarlet7
Comment Utility
Try it like this (assumes that your table/query name is "Light_Audits"):

rstLight_Audits.Open "SELECT * FROM Light_Audits;", objADOConn, 1, 1
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 200 total points
Comment Utility
Sorry, that should have been:

rstLight_Audits.Open "SELECT * FROM Light_Audits;", objADOConn, 2, 3
0
 
LVL 3

Author Comment

by:colinspurs
Comment Utility
table/query name is "Light_Audits" - correct.

This worked.  Then I replaced the SQL with the table name and that also worked, so it must have been the enums.  If I want to use the enums do I need to check a reference somewhere?  If so, how/where?

Thanks alot - points will be yours.

Colin.
0
 
LVL 15

Expert Comment

by:will_scarlet7
Comment Utility
This page discusses the Open Method for ADO Recordsets and the enums
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthrstopen.asp
0
 
LVL 3

Author Comment

by:colinspurs
Comment Utility
Thanks again.
0
 
LVL 15

Expert Comment

by:will_scarlet7
Comment Utility
Glad I could be a help. ThanX for the points!
God bless!

Sam
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Outlook 2013 Signature Image resizing 3 25
outlook 2013 key shortcuts 28 37
shared Outlook Mailbox Question 6 35
outlook 4 22
Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
If you don't know how to downgrade, my instructions below should be helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now