Good morning, I have a Switchboard with Five buttons on it, one of those buttons is for the Maintainance Tables. Is there a way, so that when that button is clicked, it asks for a password? Thank you to anyone answering this question.
I would suggest that you have the password stored in a table, one of which users will not see.
In VBA, you can setup 3 variables, 2 of which would be global in in a standard module, if not actually placed in a DB file as that would be a better place for it.
Dim PWFail as Long, DateFail as Date
On the click Event of the button, put in the following type of line:
Private Sub cmdCommandButton1_Click()
Dim Response as String, X as Long
If Now - DateFail > .333 Then
PWFail = 0
End If
If PWFail > 3 Then
Msgbox "This table is currently locked out.
Exit Sub
End If
PWRequest:
Response = InputBox("Enter password to continue."
'at this point, conpare the Response variable to the password in the DB. If it does not match, give the user an option to either go back to the switchboard of try again by something like the following:
PWFail = PWFail + 1
If PWFail < 3 Then
X = MsgBox("Would you like to try again?",276)-7
Else
Msgbox "You have been locked out of the option",48
X = 0
End If
If X Then
Goto PWRequest
End If
End Sub
Please note, the above code is not a complete code, but rather meant to show as an example.
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
Thank you for the assistance, rdodge. I take it that you use this code a module/function? How do I call it? I tried to add a procedure to the switchboard event once before, I would really not like to go down that trail again. Thank again.
If it's a command button that you are using on your switchboard as I suspect it is, right click on the command button in Design View, then click on Properties.
Now click on "Events" tab.
Look for "OnClick" and click in the textbox portion
Click on the command button to the right of the textbox with the 3 dots on it
Now click on "Code"
Put in your code.
With regards to how data is processed, Access primarily runs off of the different events. Of course, you could use macros in stead of VBA, but that is what I use, VBA as VBA in general provides for greater flexibility.
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
I would strongly suggest you do it differently...Access has user-level security built in to it. Anything you build yourself will be less secure, and unless you spend a huge amount of time on it, will have far fewer features. Plus, there will be a much smaller group of people who know how to use it.
MS has put together a FAQ about the built-in security. It takes a while to digest it all, but once you do, you will have an extremely powerful tool at your finger tips. You can get it from MS, and there's a copy of it on my website.
Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
Thank you gentlemen for all od the assistance. I will try MS, I have already try running a function in the switchboard, and I don't think I will ever do that again. It took me two hour to undo everything. Taahnk you again.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.