Link to home
Start Free TrialLog in
Avatar of doddwell
doddwellFlag for United Kingdom of Great Britain and Northern Ireland

asked on

DisableByPassKey Access Data Project

Hello

I am trying to disable the use of the shift key on startup.  I am using an Access 2003 (Access Data Project).  I am using the change property function on the MS site but it has no effect.

I am using this function....it fails because the dbs variable is set to 'Nothing' when it gets to ' dbs.Properties(strPropName) = varPropValue'


Function ChangeProperty(strPropName As String, _
 varPropType As Variant, varPropValue As Variant) As Integer
' The current listing in Access help file which will
' let anyone who can open the db delete/reset any
' property created by using this function, since
' the call to CreateProperty doesn't use the DDL
' argument
'
 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, _
        varPropType, varPropValue)
  dbs.Properties.Append prp
  Resume Next
 Else
  ' Unknown error.
  ChangeProperty = False
  Resume Change_Bye
 End If
End Function
ASKER CERTIFIED SOLUTION
Avatar of Leigh Purvis
Leigh Purvis
Flag of United Kingdom of Great Britain and Northern Ireland image

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 doddwell

ASKER

Well that was easy...thanks.  Why was I bothering with the complex function?....was that required with earlier versions of Access?
No probs.

It was required back in Access 97.
And I'd say that many developers (myself included) have just kept using their same old stock function.
(I made the above function up just now :-)

It would work in Access 2000 onwards (which is where ADP's can feature too).
Your previous function would generally work in Access 2003 mdb's - but in an ADP there is no Jet engine processing, no DAO library - and the DAO objects (like CurrentDb) aren't created.