LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Connecting Excel to Access Using Late Binding

That seemed to do it! Thanks y'all!!!
--
Dr. M


"Bob Phillips" wrote:

You can't use the library constants if you use late binding, so replace

adStateOpen

with the value 1

--
__________________________________
HTH

Bob

"Dr. M" wrote in message
...
Thanks for the tip. However, I'm trying to avoid having to reference the
Active X Data Objects Lib X.X by clicking it as I'm unsure which machine
will
actually be running this code. I was hoping more for a programmtic
solution.

Thank you!
--
Dr. M


"Office_Novice" wrote:

Try This, this worked for me after referencing Active X Data Objects Lib
2.7

Public Const ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C\: YourDataSource Here."

Public Sub Zero()
Dim Connection As ADODB.Connection
Set Connection = New ADODB.Connection
Connection.Open (ConnectionString)

If Connection.State = adStateOpen Then MsgBox "You Have Connected
Successfully ", vbInformation
If Connection.State = adStateClosed Then MsgBox "Sorry, Connection
Failed", vbCritical

If Connection.State = adStateOpen Then Connection.Close
End Sub


"Dr. M" wrote:

Hello! I'm trying to connect to an Access database using Late Binding
but my
little simple code will not open the database. I appreciate your
help!!!

Sub Test()

Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=M:\database.mdb;"

Dim cn As Object
Set cn = CreateObject("ADODB.Connection")

cn.Open strConnection

' Find out if the attempt to connect worked.
If cn.State = adStateOpen Then
MsgBox "You are connected!"
Else
MsgBox "Sorry. You are not connected."
End If

' cn.Close

End Sub

--
Dr. M




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
Late Binding access reference in Excel Module Noemi Excel Programming 0 November 16th 07 12:54 AM
Late Binding Excel in Access [email protected] Excel Programming 1 July 31st 06 03:38 PM
Late Binding examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
late binding in excel Grey Excel Programming 2 May 24th 04 08:26 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"