Link to home
Start Free TrialLog in
Avatar of Clive Beaton
Clive BeatonFlag for Australia

asked on

How to set database System Options

Can I turn off System Option 'Use Access Special Keys' in VBA?

If so, I would appreciate a line of code.

Thanks in advance,

CRB
ASKER CERTIFIED SOLUTION
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Clive Beaton

ASKER

Thanks, Crystal.  You're  a wiz.

CRB
What is the version of Microsoft Access you are using?

If you are using 2003 version then try the code below -
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
          Dim dbs As Database, prp As Property
          Const conPropNotFoundError = 3270
10        Set dbs = CurrentDb
20        On Error GoTo Change_Err
30        dbs.Properties(strPropName) = varPropValue
40        ChangeProperty = True
          
Change_Bye:
          Exit Function
          
Change_Err:
          If Err = conPropNotFoundError Then  ' Property not found.
              Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
              dbs.Properties.Append prp
              Resume Next
            Else        ' Unknown error.
              ChangeProperty = False
              Resume Change_Bye
          End If
          
End Function

Open in new window

and call -
ChangeProperty "AllowSpecialKeys", dbBoolean, False

Open in new window


To reverse it (turn them back on):
ChangeProperty "AllowSpecialKeys", dbBoolean, True

Open in new window