File Path

Oldsoftboss

AWF VIP
Local time
Today, 17:45
Joined
Oct 28, 2001
Messages
2,499
I've seen it here somewhere, but after searching for an hour, reluctantly decided to post.

I am using the FormIcon function on some of my forms.
In the Form - Load Event SetFormIcon Me.hWnd, "C:\Program Files\My App\myicon.ico" 'Location of icon file
This works fine when the icon is in this directory, but what if it is moved?

If the Icons are always located in the same directory as the .mdb can I use code to do the following:
SetFormIcon Me.hWnd, "Current Access Path - myicon.ico somehow.
I saw some code here recently that picked the current path to something but can't for the life of me find it.
Dave
 
X = CurrentDb.Name
will provide the full db path. You can then manipulate the string, e.g. search for last "\" (instrrev if you have access 2000 or xp) to give the current folder.
Hope this helps
 
If you want just the path to the current database, then use...

Left(CurrentDb.Name,Len(CurrentDb.Name)-Len(Dir(CurrentDb.Name)))
 
I think I will still need help to impement

SetFormIcon Me.hWnd, Left(CurrentDb.Name,Len(CurrentDb.Name)-Len(Dir(CurrentDb.Name))) & "myicon.ico"

Would something along that line work?
 
You almost had it for you needed to add the \ before the file name since the code returns the path to the db.

SetFormIcon Me.hWnd, Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "\myicon.ico"

When in doubt with strings, I will use a message box to display the string value I am having problems with.

HTH
 
Last edited:
Thanks for clearing that up. Have copied the line to a word doc for future reference.
Dave
 
just to say thanks as well - i was just about to ask the same question :)
 

Users who are viewing this thread

Back
Top Bottom