View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dr. M Dr. M is offline
external usenet poster
 
Posts: 11
Default Connecting Excel to Access Using Late Binding

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