Solved

error 3001 when opening recordset

Posted on 2004-09-07
9
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 11998452
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
ID: 12000859
Nope - tried it and got same error (removed adCmdTable also).

0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12000916
Question: What is the name of the table/query that you are trying to connect to?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 15

Expert Comment

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

rstLight_Audits.Open "SELECT * FROM Light_Audits;", objADOConn, 1, 1
0
 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 200 total points
ID: 12001055
Sorry, that should have been:

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

Author Comment

by:colinspurs
ID: 12004577
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
ID: 12004682
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
ID: 12004745
Thanks again.
0
 
LVL 15

Expert Comment

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

Sam
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
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…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

734 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