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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force set the icon location? 1

Status
Not open for further replies.

ov3rdr1ve

IS-IT--Management
Oct 20, 2004
32
US
I am building an installer for my new Access Project and am running into an icon issue.

Is there any way to set the icon for the Access DB to lookin inside the folder it resides in? Right now I am having to set a hard value to it (ex. c:\project\project.ico)

I would like to be able to set it to "wherever" the DB resides in, this way a user can install the DB on a network drive for everyone to use and everyone will still see the DB icon... something like this (ex. \project.ico)

But that does not work?

Any ideas!
Thanks~
od~
 
From the database window, goto Tools|Startup, select Appliation Icon and browse to it.
 
I do that... but it only allows me to select a physical location (ex. c:\project\project.ico) which I can do fine.

However, if the user installs this DB on a network drive for all to share, the other users do not have this icon in the specified location, so the others are not able to see the DB icon?

I would like to set the icon in the DB (as you suggested) to a set location of "wherever the database is" something like (ex. \project.ico) or (ex. \\project.ico). Of course these are not working for me?

I hope that is clear as mud...

Thanks
Chance~
 
If you don't mind a Lowly Technical User's thoughts, would it be possible to put the icon in the same drive as the program? Where the program is accessed through the network, can the *.ico be there as well?

I hope that you understand what I'm trying to get at.

RobotMush (Technical User)
 
It appears that you don't really know where your users will install the database. Consequently, I believe you might have to set the location for the icon when the db opens. Check out online help for the AppIcon Property
 
The problem is that you have to set the icon in the DB with a hard set location. I do have the icon in the same default location as the Database. In fact one step beyond that I have created an installer which copies the icon into the same directory the Database is installed on.

However, since all networked drives are different (e:\, f:\, g:\ etc...) there is no way to set the DB to go to the directory that the DB is installed in.

Right now I have set the icon in the Database to look in the folder that it is currently located on my HD. However, when I move it to the LAN on a networked drive and others use the same DB... they obviously do not get the icon, becuase the DB is saying "look for it on a specified drive".

Thats why I am wondering if there is a way to tell it (the DB) to look for the icon in the same location as the DB resides?

Thanks!!
any other suggestions are very welcome!

od~
 
You don't want to use drive letters. Rather, use share names. Something like this:

\\ServerName\folder\name.ico
 
The problem there is it really has to be dynamic... this program will be used by other people at other companies as well... it really needs to be a dynamic address rather than anything static.

Thanks though!
od~
 
How are ya ov3rdr1ve . . . . .

Can do! . . . .

Using [purple]CurrentDB.Name[/purple] (which returns the full path & filename of the current database) we can extract the database folder path. To that we [blue]simply append the .ico filename.[/blue] After that is a matter of manipilating the [purple]AppIcon Property[/purple] and updating with the [purple]RefreshTitleBar Method.[/purple]

There's one small catch however . . . . [blue]Its up to your installer to copy the proper icon file to the same folder as the database, renaming it if necessary to the common Icon filename[/blue] in code [purple]App.Ico[/purple]. [blue]As an alternative you can set a common icon filename in the code.[/blue] If you don't use either one of the above methods, you'll have to have a database for each seperate icon . . . . and I doubt you want to do that.

The originating call is from an [blue]AutoExec Macro[/blue], [blue]RunCode[/blue] line set to: [purple]AddAppIcon()[/purple].

After the [blue]AutoExec macro[/blue] is setup, copy/paste the following functions in a new or existing module in the modules window.
Code:
[blue]Public Function dbCurDir() As String
   Dim dbPath As String, dbFile As String
   
   dbPath = CurrentDb.Name
   dbFile = Dir(dbPath)
   dbCurDir = Left(dbPath, Len(dbPath) - Len(dbFile))

End Function

Public Function AddAppIcon() As Integer
    Dim db As Object, prp As Variant
    Dim prpName As String, prpType, icoPath As String
    
    Set db = CurrentDb()
    Const conPropNotFoundError = 3270
    prpName = "AppIcon"
    prpType = DB_Text
    icoPath = dbCurDir() & "[purple][b]App.ico[/b][/purple]" [green]'Icon filename[/green]
    

    On Error GoTo AddProp_Err
    db.Properties(prpName) = icoPath
    Application.RefreshTitleBar
    AddAppIcon = True

AddProp_Bye:
    Exit Function

AddProp_Err:
    If Err = conPropNotFoundError Then
      Set prp = db.CreateProperty(prpName, prpType, icoPath)
      db.Properties.Append prp
      Application.RefreshTitleBar
        Resume
    Else
      AddAppIcon = False
      Resume AddProp_Bye
    End If
    
    Set db = Nothing

End Function[/blue]
Thats it . . . . give it a whirl and let me know . . . .

Calvin.gif
See Ya! . . . . . .
 
Thanks for the information!!

I think this will "fit my bill"

THanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top