David A. Osborn wrote:
Is there a way to make the OLEDBConnection to my Access file relative to the
path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.
For standard security
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;"
If using a Workgroup (System Database)
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:System Database=MySystem.mdw", _
"myUsername", "myPassword"
Note, remember to convert both the MDB and the MDW to the 4.0
database format when using the 4.0 OLE DB Provider.
If MDB has a database password
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:Database Password=MyDbPassword", _
"myUsername", "myPassword"
If want to open up the MDB exclusively
oConn.Mode = adModeShareExclusive
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"