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!

Programmatically change Application Icon in an Access 2000

Status
Not open for further replies.

30101

Technical User
May 22, 2002
18
GB
How do I programmatically change the Application Icon in an Access 2000 database with my own custom built icon.
I am aware that you can change it by using built in access startup option. Tools>>> StartUP>>>Application icon.


Thank you for your help
eddie.
 
From the Access help:

Sub cmdAddProp_Click()
Dim intX As Integer

intX = AddAppProperty("AppTitle", dbText, "My Custom Application")
intX = AddAppProperty("AppIcon", dbText, "C:\Windows\Cars.bmp")
RefreshTitleBar
End Sub

Function AddAppProperty(strName As String, varType As Variant, varValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo AddProp_Err
dbs.Properties(strName) = varValue

AddAppProperty = True

AddProp_Bye:
Exit Function

AddProp_Err:
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strName, varType, varValue)
dbs.Properties.Append prp
Resume
Else
AddAppProperty = False
Resume AddProp_Bye
End If
End Function
 
Hi beetee,
Thank you for the code, I take it that I should put the code in a module and where do I call it from?

Eddie
 
You could also try this in the On Load event of the Form that Loads at Startup. Replacing C:\windows\help.ico with the path and name of your own icon. Edit or remove the Error Handling to best suit your purposes:

Dim dbs As Database
Dim prpIcon As Property
Dim strIcon As String
On Error GoTo ErrAppIcon
Set dbs = CurrentDb
Set prpIcon = dbs.CreateProperty("AppIcon", dbText, "C:\windows\help.ico")
dbs.Properties.Append prpIcon
Application.RefreshTitleBar
dbs.Close
Exit Sub
ErrAppIcon:
MsgBox err.Number & " ; " & err.Description
 
Thank you all for the useful tips. It worked!!!

Eddie
 
Say, Bill, wouldn't it make a lot more sense to use an autoexec macro that runs Startup code to do this?

What if your startup form changes?
 
Hi beetee,

That's a good idea, but where to put my example code was just a suggestion as was yours. Eddie didn't say when or where he wanted to set the icon or how often.

Keep up the good work.

Bill
 
Hello beetee and billpower,

I would just like to ask how to use your codes. I tried applying them as a module (beetee's code) and as an onload event (billpower's code). But I didn't get results for either one. I know I did something wrong in applying your codes. Can you guys give me an explanation? Thanks!

When I use the startup options to specify a custom icon for the database and I deselect the display database window checkbox, the database window is still displayed when I launch the database. Do your codes have the same effect guys? Please reply soon. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top