I want to use a button for password protecting method. Tried out the following code. But it isn't working properly.
Could you please specify the bugs and could you please handle these?
Thank you million times.
If InputBox("password") = "thepassword" then
Docmd.OpenForm formname
Else
MsgBox "You are not authorized!",vbOKOnly
End if
Private Sub Open_Activities_Menu_Click()
If InputBox("Enter password") = "111111" Then
DoCmd.OpenForm Activities_Menu
Else
MsgBox "You are not authorized!", vbOKOnly
End If
End Sub
The issue is the DoCmd line where I get a message
Run-time error '2494':
The action or method requires a Form Name argument
Your help is very much appreciated,
Thank you.
How to use password in MS Access
Hi
Here is the solution for your problem
Just write the code as follow assuming the command button name is Command42
—————————————————
Private sub command42_Click()
 On Error Goto Err_command42_Click
   Dim stDocName As String
   Dim stLinkCritieria As String
If input ("password") ="thepassword" Then
    stDocName="Form Name"
    DoCmd.OpenForm stDocName,,,stLinkCriteria
Else
    MsgBox "You are not Authorized", vbOKOnly
End If
Exit_Command42_Click:
    Exit Sub
Err_Command42_Click:
   MsgBox Err.Description
   Resume Exit_Command42_Click
End Sub
—————————————–
and It will work with youÂ
the idea here is to create a button to open form normally using the wizard then you do some changes on it to put the condition of password and make the restriction
How to use password in MS Access
Â
I use MS Access a lot but i want to keep my files safe and locked. So i tried putting passwords but it didn’t work. I really needed a solution for this problem because my files need protection from my "nosy" brother. Thanks to techyv.com and the expert for solving the issue. You have literally saved my life. Thank you very much. It works 100% now!