PDA

View Full Version : Solved: Problem with DB Path



pannai
01-09-2007, 12:28 AM
Hi
I am using Access DB to load data to excel. I have placed the DB in the same directory as that of excel file. So I have coded Db connection as followsSet dbcon = New ADODB.Connection
dbfile = "pg.mdb"
dbcon.Open "Provider=Microsoft.Jet.Oledb.4.0;data source=" & dbfile & ";"

When I open the excel file using File -> open, it is working fine. But if I open the excel file by double click or from recent files option, it gives me the following error

"Could not fild file c:\documents and settings\administrator\pg.mdb"

Can anyone help me?

Thanks in advance

gnod
01-09-2007, 12:42 AM
you need to specify the full path of your mdb..


strMdbFilename = "Expense.mdb"
strMdbPath = ThisWorkbook.Path & "\" & strMdbFilename
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strMdbPath & ";"

pannai
01-09-2007, 12:46 AM
Hi
It is working fine. Thanks for you help