Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

change hard code path to this workbook

excel vba...2010

What I need:
I need to change this hard code path so this  access database will be read from any path where this workbook is opened from.
?





Dim cn As ADODB.Connection, rs As ADODB.Recordset
Dim strConnection As String, strDBName As String, strPassword As String
Dim strTime As String
   On Error GoTo DataIsCurrent_Error


strDBName = "C:\Program Files\FieldSales\FieldSalesData.mdb"


strPassword = "123QQxx0919AZAZazaz"
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBName _
            & ";Mode=ReadWrite;Persist Security Info=False" _
            & ";Jet OLEDB:Database Password=" & strPassword
Set cn = New ADODB.Connection
cn.Open strConnection
Set rs = New ADODB.Recordset
0
Fordraiders
Asked:
Fordraiders
  • 3
1 Solution
 
Martin LissOlder than dirtCommented:
strDBName = ThisWorkbook.Path & "\FieldSalesData.mdb"
0
 
Martin LissOlder than dirtCommented:
Did that help?
0
 
FordraidersAuthor Commented:
thanks
0
 
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2013
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now