I'm writing code to open .chm files from VBA, but I need to know the location of the database to be able to open the file, which is in the same directory. Is there any way to find this out?
VB has App.Path, but VBA doesn't..
Printable View
I'm writing code to open .chm files from VBA, but I need to know the location of the database to be able to open the file, which is in the same directory. Is there any way to find this out?
VB has App.Path, but VBA doesn't..
This is for Access.
Then use InstrRev to strip off the database name and the rest will be the database folder path.Code:Dim oCnn As ADODB.Connection
Dim oRs As ADODB.Recordset
Dim sPathFull As String
Set oRs = New ADODB.Recordset
Set oCnn = New ADODB.Connection
sPathFull = Application.CurrentDb.Properties("Name").Value
If oCnn.State = adStateClosed Then
oCnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPathFull & ";Persist Security Info=False"
oCnn.Open
End If
oRs.Open sSQL, oCnn, adOpenForwardOnly, adLockReadOnly, adCmdText
This is part of some code I use to do an export of a query to a text file.