app.path in access 97 module

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In a VBA module in Access97 I want to call a shelled application.

shell(app.path & "\myapp.exe")

I can't seem to figure out which reference I will use to provide the
app.path function to me. I get a library or function not found.

or can I get the application path using application. in someway?

thanks

Chris
 
Private Const OBJ_NAME = "modSystem"


'****************************************************************************************
' Function Name: appPath
'
' Description:
' Returns the absolute path of the MS Access database in use.
'
' NOTE:
' The returned path does not include the trailing '\' at the end.
' i.e. C:\Development\...\myfolde
'****************************************************************************************
Public Function appPath() As String
Dim ErrMsg As String
Dim ErrNo As Long
Dim dbPath As String
Dim path As String
Dim pos As Integer

On Error GoTo proc_err

'Obtain the full path to the MS Access DB in use. Keep in mind that
'i.e. C:\...\mydb.mdb
dbPath = CurrentDb.Name

'Continue if the a path was returned
If Len(dbPath) > 0 Then
'Iterate through the path string until the last '\' character
'has been reached
pos = InStr(dbPath, "\")

Do While pos > 0
'Save the potiential sought path
'NOTE:
' Change pos -1 to pos to include the trailing '\'
' at the end of the returned path
path = Left(dbPath, pos - 1)

'Conduct a check to determine if the last '\' has been reach
'in db's path string
pos = InStr(pos + 1, dbPath, "\")

Loop

'Now, exclude the name of the database name and return
'only the path


Else
'No path was retrieved
path = ""

End If

'Return path to calling function
appPath = path

Exit Function

proc_err:
ErrNo = Err.Number
ErrMsg = Err.Description

On Error Resume Next
appPath = ""

Err.Raise ErrNo, OBJ_NAME & ".appPath", ErrMsg

End Function


I hope this helps. Cheers.
MMS
 
Not my idea, just something I picked up from the newsgroups.

In later versions of Access you can use CurrentProject.Path, but that was
new in Access 2000, so won't work in Access 97.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top