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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CurrentDB Error

Status
Not open for further replies.

darkhat01

IS-IT--Management
Apr 13, 2006
144
0
0
US
I am having a problem with setting the Data Source when it is set to CurrentDB. If I set the path to c:\test\mydatabase.mdb it works fine. Why will this not work, does anyone have an idea?


Code:
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

    objConnection.Open _
    "Provider = Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source = CurrentDB" 'Location of Current database

objRecordSet.Open "SELECT * FROM Answers1", _
    objConnection, adOpenStatic, adLockOptimistic

Set objFSO = CreateObject("Scripting.FileSystemObject") 'Create FOS Object
Set objFile = objFSO.OpenTextFile(strFilepath)          'Open file to Import

Thank you,

Darkhat
 
What about this ?
"Data Source = " & CurrentDB.Name 'Location of Current database


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV... Sorry that is took so long to get back to you... I had an emergancy and have been out of town for awhile... I am going to try this now.

Darkhat01
 
PHV,

That worked like a charm....

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top