View Full Version : File Path


Oldsoftboss
02-06-2003, 01:46 AM
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

Keith P
02-06-2003, 10:58 AM
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

ghudson
02-06-2003, 01:34 PM
If you want just the path to the current database, then use...

Left(CurrentDb.Name,Len(CurrentDb.Name)-Len(Dir(CurrentDb.Name)))

Oldsoftboss
02-07-2003, 12:27 AM
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?

ghudson
02-07-2003, 05:57 AM
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

Oldsoftboss
02-07-2003, 09:11 PM
Thanks for clearing that up. Have copied the line to a word doc for future reference.
Dave

RobinL
02-08-2003, 09:15 AM
just to say thanks as well - i was just about to ask the same question :)