Stuart McLachlan
stuart at lexacorp.com.pg
Thu Mar 10 17:46:49 CST 2011
I use a more generic Function where you pass the property type as well:
SetProperty "AllowBypassKey", dbBoolean, False
Public Function SetProperty(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Long
On Error GoTo Err_SetProperty
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperty = True
Set db = Nothing
Exit_SetProperty:
Exit Function
Err_SetProperty:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperty = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperty
End If
End Function
On 10 Mar 2011 at 16:40, Carolyn Johnson wrote:
> Public Sub ChangeAppProperty(ByVal sName As String, ByVal bValue As
> Boolean) Dim prp As DAO.Property
>
> On Error Resume Next
>
> CurrentDb.Properties(sName) = bValue
> If Err.Number = 3270 Then
> Set prp = CurrentDb.CreateProperty(sName, dbBoolean, bValue)
> CurrentDb.Properties.Append prp
> End If
>
> End Sub
>
>
> I have a comparable sub for properties that have text values rather
> than boolean values.
>
>