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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=c:\somep ath\myDb.mdb;"
If using a Workgroup (System Database)
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:System Database=MySyst em.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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:Database Password=MyDbPa ssword", _
"myUsername ", "myPassword "
If want to open up the MDB exclusively
oConn.Mode = adModeShareExcl usive
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"