Hi all,
I am using Access 2000
I found some code which should allow my app to set the app icon when it loads up, assuming that it is in the same folder as the database. The reason for wanting to do this is so that when I distribute the db to other departments their path to the db and the icon file will not be the same as mine. SO I need it do it wherever a user keeps it as long as the icon file is in the same directory as the db.
unfortunately when I tried running the code it did not work becauseoff an error access 2000 threw up. It is possible that the code was written for Access 97, as the thread was back in 2001 about May time I think.
I was going to reference the thread here but my computer crashed and I cant seem to find the thread now.
the bit which causes the problem is
the code which reads
Set prp = dbs.CreateProperty(strPropName, _
PropType, varPropValue
in the function changeproperty
the problem it gives is type mismatch, i'm not knowledgeable enough to find out whats wrong can someone help ??
Idd
here is the code
--------------------------
start of code
-------------------------------------
Function SetStartupProperties()
'Set icon what location is same DB location's
ChangeProperty "AppIcon", dbText, DirOfFile & "staff lookup.ico"
End Function
'--------------------------------------------
'next function
'--------------------------------------------
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
PropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
'--------------------------------------------
'next function
'--------------------------------------------
Function DirOfFile(Optional strPath As String = "", Optional blnMasterDir As Boolean = False) As String
'Directory of file
DirOfFile = strPath
Dim i As Byte
If strPath = "" Then strPath = CurrentDb.Name
For i = 1 To Len(strPath)
If Mid(strPath, i, 1) = "\" Then
DirOfFile = Left(strPath, i)
If blnMasterDir = True Then
If i > 1 Then
If Mid(strPath, i - 1, 1) <> ":" Then
Exit For
End If
End If
End If
End If
Next i
End Function
I am using Access 2000
I found some code which should allow my app to set the app icon when it loads up, assuming that it is in the same folder as the database. The reason for wanting to do this is so that when I distribute the db to other departments their path to the db and the icon file will not be the same as mine. SO I need it do it wherever a user keeps it as long as the icon file is in the same directory as the db.
unfortunately when I tried running the code it did not work becauseoff an error access 2000 threw up. It is possible that the code was written for Access 97, as the thread was back in 2001 about May time I think.
I was going to reference the thread here but my computer crashed and I cant seem to find the thread now.
the bit which causes the problem is
the code which reads
Set prp = dbs.CreateProperty(strPropName, _
PropType, varPropValue
in the function changeproperty
the problem it gives is type mismatch, i'm not knowledgeable enough to find out whats wrong can someone help ??
Idd
here is the code
--------------------------
start of code
-------------------------------------
Function SetStartupProperties()
'Set icon what location is same DB location's
ChangeProperty "AppIcon", dbText, DirOfFile & "staff lookup.ico"
End Function
'--------------------------------------------
'next function
'--------------------------------------------
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
PropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
'--------------------------------------------
'next function
'--------------------------------------------
Function DirOfFile(Optional strPath As String = "", Optional blnMasterDir As Boolean = False) As String
'Directory of file
DirOfFile = strPath
Dim i As Byte
If strPath = "" Then strPath = CurrentDb.Name
For i = 1 To Len(strPath)
If Mid(strPath, i, 1) = "\" Then
DirOfFile = Left(strPath, i)
If blnMasterDir = True Then
If i > 1 Then
If Mid(strPath, i - 1, 1) <> ":" Then
Exit For
End If
End If
End If
End If
Next i
End Function