Late Binding across Several Routines

VenturSum

Board Regular
Joined
May 23, 2010
Messages
137
Guru's

I'm using late binding to connect to an access database.
I'm address this database in several routines and modules.

However I don't want to initiate the connection and close it each time I change between subroutines.

Instead I'd like to create the late bind once.
and access it whenever needed.


Code:
Dim objAccess As Object 
Dim sFullPath as string    'Path and Name of database

   'Establish Late Bind
    Set objAccess = CreateObject("Access.Application")
    objAccess.OpenCurrentDatabase sFullPath

    With objAccess
       'Do stuff with objAccess



    End With

   'Close Late Binding
   objAccess.CloseCurrentDatabase
   objAccess.Quit
   Set objAccess = Nothing
Any Thoughts?

John,
In Annapolis.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
I have this resolved by creating the access object as a global variable.
Then I created separate routines to create the late bind and to separate the late bind.

It worked, but it took some time.

John,
In Annapolis
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,825
Members
449,470
Latest member
Subhash Chand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top