Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to code for relative path in access2000

Status
Not open for further replies.

30101

Technical User
May 22, 2002
18
GB
Hi,
I have a working database with a custom help file, both working as planned. I use the code from the microsoft developer site see below:
Option Compare Database
Option Explicit

Public Const HELP_CONTEXT = &H1 'Display topic for Help context ID.
Public Const HELP_QUIT = &H2 'Terminate Help.
Public Const HELP_INDEX = &H3 'Display Help index.
Public Const HELP_CONTEXTPOPUP = &H8& 'Display Help context as a pop-up
'window.
Public Const HELP_FINDER = &HB& 'If found, Display container file.
Public Const HELP_KEY = &H101 'Display topic for keyword.

'Declare the WinHelp function.
Declare Sub WinHelp Lib "user32" Alias "WinHelpA" (ByVal Hwnd As Long, _
ByVal lpHelpFile As String, ByVal wCommand As Long, _
ByVal dwData As Any)

Function OpenHelpContainer(ByVal strHelpFileName As String)
'Opens the Help container.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_FINDER, ByVal vbNullString
End Function

Function OpenHelpIndex(ByVal strHelpFileName As String)
'Opens the Help index.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, HELP_KEY, _
ByVal ""
End Function

Function OpenHelpIndexWithSearchKey(ByVal strHelpFileName As String, _
ByVal strSearchKey As String)
'Opens the Help index and searches for keyword SKey.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, HELP_KEY, _
ByVal strSearchKey
End Function

Function OpenHelpWithContextID(ByVal strHelpFileName As String, _
lngContextID As Long)
'Opens the Help file to ContextID.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_CONTEXT, ByVal lngContextID
End Function

Function OpenHelpWithContextIDPopup(ByVal strHelpFileName As String, _
lngContextID As Long)
'Opens the Help file to ContextID as a pop-up window.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, _
HELP_CONTEXTPOPUP, ByVal lngContextID
End Function

Function CloseHelpContainer(ByVal strHelpFileName As String)
'Closes the specified Help file.
WinHelp Application.hWndAccessApp, ByVal strHelpFileName, HELP_QUIT, _
ByVal vbNullString
End Function

I then called the function =OpenHelpContainer("wrsu.hlp")
from my Menu bar.

How do I Programmatically code for a relative path? in case I change installed directory say from C to D drives.
So that where ever I move my application to, I dont have to worry about relinking the help file with the database as far as both are in the same folder.

Step by step please.

Thank you for your help.

eddie
 
Try:

Dim strAppPath as string
strAppPath = Application.CurrentProject.Path
 
Hi billpower,
Thank you for your reply, Where should I put this code?.When try to compile, it didn't like the "Application" bit.
Excuse me for my ignorance.


eddude
 
Hi eddie,

You didn't say which version of Access that you’re using, sounds like it's pre-Access 2000, try this instead:

Dim strThisDBPath as string
strThisDBPath = CurDir

 
Actually you did say which Version of Access you're using, in Access 2000:

This, put behind a button on a form will give you the current path of the DB the form is in:

Dim strAppPath As String
strAppPath = Application.CurrentProject.Path
MsgBox strAppPath

Bill
 
Hi Bill,
(Whao!!)I was able to call the drive path with the above code. Considering my original problem, How do I incorporate above relative path code into the called menubar function? So that when I click help icon on the bar it will open the help file irrespective of where it's located.
Hope you can follow what I am trying to do.
 
I don't really want to go any further with this Thread.

Dim strAppPath As String
strAppPath = Application.CurrentProject.Path
Help File = OpenHelpContainer(strAppPath & "\" & "wrsu.hlp")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top