Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set my ADODB connection to my current db 1

Status
Not open for further replies.

JunglesMcBeef

Programmer
Sep 18, 2003
266
G'day,

Maybe a simple one for you. Can anyone tell me how to set my ADODB connection to the database that is currently open?
 
Pass this guy an "" and it will open a local, pass it a path and it will open a Remote

Function OpenDB(ByVal dbname As String)
On Error GoTo OpenDBConnection_err

Set DB = New ADODB.Connection
If dbname = "" Then
Set DB = CurrentProject.Connection
Else
DB.Open ("Provider=Microsoft.jet.OLEDB.4.0;Data Source=" + dbname)
End If
OpenDB = True

Exit Function


'***********************
OpenDBConnection_err:
'***********************
msgbox error$

End Function
 
Perfect, I was trying to Set cnn = CurrentDB.Connection... he he he, my bad. Thanks.
 
That is not actually documented very well. I remember when I wrote that function I had to really hunt for it.
 
Ditto vbajock
Only found CurrentProject.Connection in an example. No actual reference in help detailing how to connect to local DB.
Searching thru help for something, sorry to boost an old post but felt compelled to confirm MS documentation shortfalls.
 
You think thats bad you get into .net. Nobody knows whats going on because the documentation is so bad. The desgn of the "dynamic" help system is atrocious - you get back everything but what's relevent to what you are trying to do.
In the class I just took, the professor spent more time trying to figure out why his *hit didn't work than I did on mine. What a circus.


 
There is actually a very good book for ADO in Access titled "Programming Microsoft Access Version 2002" by Rick Dobson. I have found it to be an excellent reference for ADO topics.

Phil Edwards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top