Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo ChangeProperty_Err
Dim dbs As Object
Dim prp As Variant
Const PropertyNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo ChangeProperty_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True
Err = 0
On Error GoTo 0
If Err = PropertyNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
Basically, this will only run on the next startup.
I want the code to run as soon as the button is pressed for security reasons.
I have tried my hardest to find some sort of database refresh (currentDB.refresh etc) but with no luck!
Is there another way I can lock the database for everyone except one user?
This is what I'm trying to do above with no luck so far!
Thank you in advance for any help you can give me!
Unfortunately, this is not my system, just one I am helping to "make secure" therefore I am not able to play about with tables as I would like.
Can you elaborate on what you mean by "visible set to false" please?
If I understand correctly, I already have the button implemented for the one user only, based on their username.
The problem is, when I run this code, I have to exit, then re-launch the database for the property changes to take effect. This means that when it is unlocked, the next person (regardless of username etc) can access everything.
I just need to refresh the properties/apply the changes without having to close the database.
you say that the code only runs when the db is restarted?
the code is run when the command button is clicked but the properties you are changing are "startup" properties so the effect of them being changed from false to true will not be apparent until the db is "started up" again,
according to microsoft knowledge base you HAVE TO restart the db app.
the simple way around this might be to give the user who you want to have special privilages a seperate password protected ffont end db that is linked to the same backend db.
your administrator will have access the all required data etc, while users will use a different front end that has resricted access.
Good afternoon and Happy New Year to everyone. Why not use Access security for setting passwords and then in your code set it where only certain login/usernames are allowed to access certain data. Either make those Forms etc. Visible to that user or AllowEdits to that user. Just something to think about.
Good suggestion bud, I will talk it over with my colleague.
However, this is an existing system we are developing/making secure.
It has coded user access levels that exist already, so I was trying to come up with a way of coding in a new security level in the same way as already exists in the database.
you could get by your problem by having the db open by default with the special keys etc enabled. then using the onload event of your startup form, remove the desired menus, hide the db window and anything else. then you can give access to the desired functions depending on the user.
not an ideal way and i wouldn't be happy about users having access to the bypasskey.
if you can let me see a sample of your app i'll see if i can get anywhere with it in spare time