xhenkaii
asked on
Help in locking down database
Hi,
I'm trying to "lock" the db down so that the users cannot get into the db objects (forms, tables, modules, etc...).
I've created a new module and paste this code:
Sub SetStartupProperties()
ChangeProperty "StartupForm", dbText, "YourFormHere"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, False
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, False
ChangeProperty "AllowBreakIntoCode", dbBoolean, False
ChangeProperty "AllowSpecialKeys", dbBoolean, False
ChangeProperty "AllowBypassKey", dbBoolean, False
ChangeProperty "AppTitle", dbText, "Application Title Here vs1.2"
Application.RefreshTitleBa r
End Sub
Public 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(strProp Name, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
The key line of code here is this
ChangeProperty "AllowBypassKey", dbBoolean, False
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
but it throws me a type mismatch error.
The error happens on this line:
dbs.Properties(strPropName ) = varPropValue
and it throws the "type mismatch" on
Set prp = dbs.CreateProperty(strProp Name, _
varPropType, varPropValue)
Just to retrace my steps. I created a module and copy paste the sub and the public function into it. I've insert ChangeProperty "AllowBypassKey", dbBoolean, False into the form_load() of the switchboard. Right? Where have i gone wrong?
I'm trying to "lock" the db down so that the users cannot get into the db objects (forms, tables, modules, etc...).
I've created a new module and paste this code:
Sub SetStartupProperties()
ChangeProperty "StartupForm", dbText, "YourFormHere"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, False
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, False
ChangeProperty "AllowBreakIntoCode", dbBoolean, False
ChangeProperty "AllowSpecialKeys", dbBoolean, False
ChangeProperty "AllowBypassKey", dbBoolean, False
ChangeProperty "AppTitle", dbText, "Application Title Here vs1.2"
Application.RefreshTitleBa
End Sub
Public Function ChangeProperty(strPropName
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If ERR = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strProp
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
The key line of code here is this
ChangeProperty "AllowBypassKey", dbBoolean, False
--------------------------
but it throws me a type mismatch error.
The error happens on this line:
dbs.Properties(strPropName
and it throws the "type mismatch" on
Set prp = dbs.CreateProperty(strProp
varPropType, varPropValue)
Just to retrace my steps. I created a module and copy paste the sub and the public function into it. I've insert ChangeProperty "AllowBypassKey", dbBoolean, False into the form_load() of the switchboard. Right? Where have i gone wrong?
ASKER
I still have the type mismatch error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well i'm using access 02 but my program is in access 2000 format.
ASKER
it still throws me the type mismatch error even when i convert to access 02 format. help!
I'm pretty sure I solved it, and then I locked myself out of the database...
Change the,
Set prp = dbs.CreateProperty(strProp Name, varPropType, varPropValue)
to
prp = dbs.CreateProperty(strProp Name, varPropType, varPropValue)
And it should work. And please make a backup of the database first.... :)
Set prp = dbs.CreateProperty(strProp
to
prp = dbs.CreateProperty(strProp
And it should work. And please make a backup of the database first.... :)
Or replace the next line with:
dbs.Properties.Append dbs.CreateProperty(strProp Name, varPropType, varPropValue)
dbs.Properties.Append dbs.CreateProperty(strProp
And change the YourFormHere in,
ChangeProperty "StartupForm", dbText, "YourFormHere"
To a form that actually exists in your project... Oh yeah, did I mention making a backup copy first?
ChangeProperty "StartupForm", dbText, "YourFormHere"
To a form that actually exists in your project... Oh yeah, did I mention making a backup copy first?
ASKER
well i got it to work now. just shifted the piority of the DAO reference to the top.
(O___O)
i'm bugged about it.
Since i cant take back the points, i'll split it the nice people who tried to help me. =)
Xhenkaii
(O___O)
i'm bugged about it.
Since i cant take back the points, i'll split it the nice people who tried to help me. =)
Xhenkaii
ASKER
eternal_21,
dbs.Properties.Append dbs.CreateProperty(strProp Name, varPropType, varPropValue)
This dont work. Gave me an error with the Append dbs statement. End of statement expected.
ChangeProperty "StartupForm", dbText, "YourFormHere"
I've changed it already.
prp = dbs.CreateProperty(strProp Name, varPropType, varPropValue)
nv tried this... hahaha
anyway, i place a "ChangeProperty "AllowBypassKey", dbBoolean, True" on a dbl_click() abel in a form. So i'm able to activite the SHIFT key to edit my database. heh. Thanks anyway. The pts are urs.
dbs.Properties.Append dbs.CreateProperty(strProp
This dont work. Gave me an error with the Append dbs statement. End of statement expected.
ChangeProperty "StartupForm", dbText, "YourFormHere"
I've changed it already.
prp = dbs.CreateProperty(strProp
nv tried this... hahaha
anyway, i place a "ChangeProperty "AllowBypassKey", dbBoolean, True" on a dbl_click() abel in a form. So i'm able to activite the SHIFT key to edit my database. heh. Thanks anyway. The pts are urs.
Thanks, xhenkaii. But if you feel that you have solved the problem yourself, place a post in Community Support, and they will refund your points!
ASKER
It's no prob for the points with me, eternal. My way of saying thanks for helping.
Cheers!
Cheers!
ChangeProperty "AllowBypassKey", dbBoolean, 0