childrenfirst
Technical User
Hi,
I set up the Startup in Access Project so that users cannot get to the database and tables. However, I would also like to set up AllowByPass so that users cannot bypass Startup. I found some codes in Access Help and the Internet, but I have no idea how and where to add it to my application and how and where to call the function. In Access Help, it said to add the code to AccessObjectProperties using Add Method. It sounds like a mystery to me. Can anyone explain to me step by step how to implement the code in Access Project? Thank you!
Code found in Access Help:
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
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
I set up the Startup in Access Project so that users cannot get to the database and tables. However, I would also like to set up AllowByPass so that users cannot bypass Startup. I found some codes in Access Help and the Internet, but I have no idea how and where to add it to my application and how and where to call the function. In Access Help, it said to add the code to AccessObjectProperties using Add Method. It sounds like a mystery to me. Can anyone explain to me step by step how to implement the code in Access Project? Thank you!
Code found in Access Help:
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
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