password to untick checkbox

james_IT

Registered User.
Local time
Today, 10:47
Joined
Jul 5, 2006
Messages
208
hi guys

i have a database that has a checkbox if the stock is in stock. once this item is sold the box is unchecked.

for security reasons i wantit to request a password when the checkbox is unchecked so that only tha managers can remove stock from the database.

ive had a little search around the forum but couldnt find anything specific enough

can anyone point me in the right direction?

TIA
 
You could ask for and check a password on the Check Box's On Click event, and cancel the event if the user is unable to provide the correct password.
 
I'm pretty sure you will at least have to go the route of a macro, if not a code snippet form the 'Before Update' event of the check box.

Macros aren't my playground, but here's a code snippet to accomplish what you want.

Private Sub chkTEST_BeforeUpdate(Cancel As Integer)
If InputBox("Enter Password") <> "password" Then
Cancel = True
End If
End Sub

Now, in this, the check box control will have to be named 'chkTEST', and the password is hard-coded. You can replace this with any number of other options to validate the password. Hope this helps. ~R
 
I'm pretty sure you will at least have to go the route of a macro, if not a code snippet form the 'Before Update' event of the check box.

Macros aren't my playground, but here's a code snippet to accomplish what you want.

Private Sub chkTEST_BeforeUpdate(Cancel As Integer)
If InputBox("Enter Password") <> "password" Then
Cancel = True
End If
End Sub

Now, in this, the check box control will have to be named 'chkTEST', and the password is hard-coded. You can replace this with any number of other options to validate the password. Hope this helps. ~R

Macro not required. The code sample is just what they would need (but I think I would store the password in a table and use a dlookup or a recordset to retrieve it for comparison.
 
I agree with Bob. In an internal situation, it would probably take a grand total of a week before the hard-coded password was common knowledge. This leads to having to communicate the new password, revising the application etc., which is tedious, to say the least.

A table that holds the password value will make it easier to change, but will not alleviate the communication of the new password.

I've found that a good overall practice is to allow 'Admin' users to sign in, then retain a global variable or a 'CheckAdmin' sub using hidden controls that tags the current user as admin or not. You can also provide them with the ability to change their own password, thereby removing from the Application Administrator the need to re-communicate the new password. This will also not over-burden the user with multiple pop-ups requiring confirmation, regardless of the situation.

But that may be more than you were looking for. ~R
 
thanks guys - that code works great for the time being

can anyone point me in the right direction for some code for dlookup or recordset to check against and how this works with passwords?
 
thanks guys - that code works great for the time being

can anyone point me in the right direction for some code for dlookup or recordset to check against and how this works with passwords?

You would create a table (lets say you name it tblP for your passwords and you could have it hidden too. You name the password field PWD and then you have a field named ITEMName so you can use that table for other passwords if you need to later. You can set the password field to be PASSWORD under format and then it won't display it if someone opens the table or tries to copy from the table. Code can display it though. So as a record in that table you put in the name of CheckboxP in the ITEMName field and then the password under PWD. So then you would use something like this:
Code:
Private Sub chkTEST_BeforeUpdate(Cancel As Integer)

Dim rst As DAO.Recordset
Dim strSQL As String
 
Set strSQL = "SELECT PWD From tblP Where ITEMName = 'CheckboxPassword'"
 
Set rst = CurrentDb.OpenRecordset(strSQL)
 
If InputBox("Enter Password") <> rst!PWD Then
   Cancel = True
   Me.chkTEST.Undo
End If
 
rst.Close
Set rst = Nothing
 
End Sub
 
What I do is add an unrelated table like 'tblAdminString'. this table has two fields, 'StringName' and 'StringValue'.

Then your DLookup would be something like:

DLookup("StringValue", "tblAdminStrings","StringName = 'AdminPWord'"). ~R
 

Users who are viewing this thread

Back
Top Bottom