Results 1 to 8 of 8

Thread: Solved: Early Binding ADODB from Excel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,446
    Location
    The idea Dr.K is to have the option to run it early bound or late bound. You could do what you say, or you could use conditional compliation on the constants, together with something like this

    [vba]

    #If EarlyBound Then
    Dim oConn As ADODB.Connection
    Dim oRS As ADODB.Recordset

    Set oConn = New ADODB.Connection
    oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DBPath
    Set oRS = New ADODB.Recordset
    #Else
    Dim oConn As Object
    Dim oRS As Object

    Set oConn = CreateObject("ADODB.Connection")
    oConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & DBPath
    Set oRS = CreateObject("ADODB.Recordset")
    #End If
    [/vba]
    Last edited by Bob Phillips; 11-20-2007 at 07:48 AM.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •