PC Review


Reply
Thread Tools Rate Thread

Access 2003 VBA Open Recordset

 
 
New Member
Join Date: Jun 2011
Posts: 1
 
      30th Jun 2011
Hi everyone,

I'm relatively new to VBA and definitely new to Access (2 weeks). I need some help with the following code:

Sub Repeat_ED_Visits()
Dim q1New As Object
Dim sql As String
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim EDRepeatTbl As TableDef
With CurrentDb
sql = ("SELECT DISTINCT ...") 'my SQL query
Set q1New = .CreateQueryDef("EDRepeatQuery", sql)
End With
Set rst = New ADODB.Recordset
Set cnn = New ADODB.Connection
Set cnn = Application.CurrentProject.Connection
rst.Open sql, CurrentProject.Connection
With rst
<<code>>
End With
rst.Close
Set rst = Nothing
End Sub

When I run this, I'm getting error msg 3704 ("Operation is not allowed when the object is closed"), but my rst.Open line is there. Any ideas?

Thanks in advance,
Anh
 
Reply With Quote
 
 
 
 
Banned
Join Date: Jul 2011
Posts: 16
 
      23rd Jul 2011
Check whether the ADODB (Microsoft ActiveX Data Object n.n Library) Library File is attached to your Project or not.

  1. Open VBA Window (Alt+F11)
  2. Select References from Tools Menu.
  3. Browse for the above Library File (if it is not already selected) and put a check mark in the Dialog Control.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you doubleclick on a recordset to open recordset in form vi =?Utf-8?B?Si4gS2VnZ2VybG9yZA==?= Microsoft Access Form Coding 3 4th May 2007 08:56 PM
How to open Access recordset via Query in Excel VBA??? Hexman Microsoft Excel Programming 4 29th Mar 2006 08:11 PM
Access 2002: bind adodb recordset to listbox recordset property Craig Buchanan Microsoft Access Form Coding 2 1st May 2005 12:14 AM
Type recordset/recordset? FlaviusFlav Microsoft Excel Programming 4 24th May 2004 12:16 PM
ADO - Modifying a Recordset with VBA - Where is Recordset.Edit?? JDeBeer Microsoft Access VBA Modules 2 30th Oct 2003 06:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:13 AM.