Solved

Want to connect Access 2007 to SQL Server 2008

Posted on 2011-09-09
3
274 Views
Last Modified: 2012-05-12
Hi Everybody,

I am trying to connect my Access 2007 database to a SQL Server  2008 database. I have tried the following string that I found, but it is not working.
---------------------------------------------------------------------------------------------------
Private Sub Command0_Click()

Dim MyConnObj As New ADODB.Connection    <--- Problem highlighted in yellow here
Dim myRecSet As New ADODB.Recordset
Dim sqlStr As String

MyConnObj.Open _
 "Provider = sqloledb;" & _
 "Data Source=timvmsql1;" & _
 "Initial Catalog=TESTWORLD;"


   sqlStr = "select * from contacts"

   myRecSet.Open sqlStr, MyConnObj, adOpenKeyset

   MsgBox "Total Number of records = " & myRecSet.RecordCount


End Sub
---------------------------------------------------------------------------------------------

It does not seem to recognize the ADODB functionality. Is there somewhere that I need to enable this functionality or is there another method?  Perhaps DAO?

Thanks,
0
Comment
Question by:jonsuns7
  • 2
3 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 36514349
Do you have the ADO library loaded as a reference in your VBE?

Tools-->References-->
0
 

Author Closing Comment

by:jonsuns7
ID: 36514969
I had figured out the answer, that was the same as you mentioned. But since nobody else answered, I'll give you the points. Have a good weekend.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36515010
ok
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

770 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