如何使用密码保护复选框?

时间:2022-09-16 23:01:34

I have a question on checkboxes in acess 2003

我对acess 2003中的复选框有疑问

I have 4 checkboxes on my form and one of these boxes, i want to restrict so only users supplied with the correct password eg (report1) can check that box. I have a small textbox to the side of the checkbox labelled manager password.

我的表单上有4个复选框和其中一个复选框,我想限制所以只有提供正确密码的用户(例如(report1))才能检查该框。我在标有经理密码的复选框旁边有一个小文本框。

I am not sure how to set this validation in access. I have right-clicked on the check box, gone to properties and seen the validation rule but not sure where to go from there. I have an idea of what my VB code will be if applicable and I am including that if it helps

我不确定如何在访问中设置此验证。我右键单击复选框,转到属性并看到验证规则,但不知道从那里去哪里。我知道如果适用我的VB代码是什么,如果有帮助我会包括它

Code Snippet If txtpassword.text = "report1" then closedsftleader.yes = true else msgbox.show "Management Password is incorrect, please try again"

代码片段如果txtpassword.text =“report1”则closedsftleader.yes = true else msgbox.show“管理密码不正确,请再试一次”

END IF

Not even sure if this code would work but its an idea. Please help when you can. Thank you.

甚至不确定这段代码是否可行,但它是一个想法。请尽可能提供帮助。谢谢。

3 个解决方案

#1


Have you considered locking or disabling this particular checkbox? For example:

您是否考虑过锁定或禁用此特定复选框?例如:

Private Sub Form_Current()
    Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub

Private Sub txtpassword_AfterUpdate()
    Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub

Disabling like this is simple for your user to understand, rather that a checkbox that seems impossible to click, furthermore, it will be easy enough to change this to refer to a global variable or user name.

像这样的禁用对于您的用户来说很容易理解,而不是一个似乎无法点击的复选框,此外,更改它以引用全局变量或用户名将非常容易。

I generally set tag properties for controls, which allows me to hide or enable controls in batches, according to the user and / or password.

我通常为控件设置标签属性,这允许我根据用户和/或密码批量隐藏或启用控件。

#2


You want to add an event on the text box (I believe it's the "changed" event) and then enable/disable the textbox based on the contents of the text box.

您想在文本框中添加一个事件(我相信它是“已更改”事件),然后根据文本框的内容启用/禁用文本框。

As a side note, this is an odd design for protecting contents of a form. You may want to consider forcing users to log in to your Access app.

作为旁注,这是用于保护表单内容的奇怪设计。您可能需要考虑强制用户登录Access应用程序。

#3


You can handle the OnClick event of the checkbox and not allow a change if the textbox doesn't have the correct password.

您可以处理复选框的OnClick事件,如果文本框没有正确的密码,则不允许更改。

#1


Have you considered locking or disabling this particular checkbox? For example:

您是否考虑过锁定或禁用此特定复选框?例如:

Private Sub Form_Current()
    Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub

Private Sub txtpassword_AfterUpdate()
    Me.closedsftleader.Enabled = (Me.txtpassword = "Report1")
End Sub

Disabling like this is simple for your user to understand, rather that a checkbox that seems impossible to click, furthermore, it will be easy enough to change this to refer to a global variable or user name.

像这样的禁用对于您的用户来说很容易理解,而不是一个似乎无法点击的复选框,此外,更改它以引用全局变量或用户名将非常容易。

I generally set tag properties for controls, which allows me to hide or enable controls in batches, according to the user and / or password.

我通常为控件设置标签属性,这允许我根据用户和/或密码批量隐藏或启用控件。

#2


You want to add an event on the text box (I believe it's the "changed" event) and then enable/disable the textbox based on the contents of the text box.

您想在文本框中添加一个事件(我相信它是“已更改”事件),然后根据文本框的内容启用/禁用文本框。

As a side note, this is an odd design for protecting contents of a form. You may want to consider forcing users to log in to your Access app.

作为旁注,这是用于保护表单内容的奇怪设计。您可能需要考虑强制用户登录Access应用程序。

#3


You can handle the OnClick event of the checkbox and not allow a change if the textbox doesn't have the correct password.

您可以处理复选框的OnClick事件,如果文本框没有正确的密码,则不允许更改。