password protect the use of a command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that is opened by the click of a command button on a
switchboard. Is there a way I can password protect the use of this button?
 
You CAN do this with Access 2003.

The standard way is to set up security for the entire database. This would
require users to log in when they open your app and allow you to assign
rights to every object in the db. There's a lot to this and the best way to
start ias with the User-level Security Wizard. This method is best if you
want each user to have their own user name and password.

If you don't want to set up security but just want to prompt the user for
that single button, it's still possible, but you'll probably just have a
single generic password. This method is far less secure for obvious reasons.
If you want to do it this way, put an input box in code and compare it to a
fixed password.

Private Sub cmdOpenRpt_Click()
If Inputbox("Enter the password","Enter Password") = "thepassword" Then
DoCmd.OpenReport "blah-de-blah"
Else
MsgBox "Incorrect password", vbOkOnly, "Beat It"
End If
End Sub

If you do it this way (which, as I said isn't very secure), don't forget to
password protect the VBA code module so prying eyes can't get at your code
and see your highly cryptic password.

Barry
 
Barry

Quite correct.

Who is Armando Blanco? His standard 'you can't do this...' is poping up all
over the place and is invariable a nonsense. Can be be blocked from the forum
perhaps?

Barry W
 
Thanks for the help. I'm sure the level of security provided by the code you
listed will be more than enough to prevent the users of the app from causing
any trouble.

By the way, I am but a student of Access (still using 2000) and I wish I
could get off the ground with VB to lift my programs to the next level. Can
you suggest a way of teaching myself (or a way to be taught) VB from a
practical approach as opposed to a theoretical approach. Up until now, I
have been picking up tidbits of VB only as needed. I would like to
accelerate the learning process if I can.

Your thoughts will be appreciated.
 
Most of the 800 page beginner Access books have a short chapter at the end
about VBA. There are also a few good books that could get you started. Check
the reviews of these books at Amazon.

One way that a lot of people get started (and the way I did many moons ago)
is to convert your macros to VBA using Tools, Macro, Convert Macros To Visual
Basic. This will create code based on the macros that already exist in you
db. The code will be fairly simple, but it might be a good way to start
getting a sense of it.

Best of luck.
Barry
 
Thank you for all your help. The code works just fine. Is there a way to
hide the password from others as it is being typed. Usually, a password
displays as a series of dots, whereas, it is appearing in the window in text
as it is being entered. Thank you again for all your help.
 
Unfortunately, you can't apply an inputmask to an inputbox to show asterisks.
You can create your own version of the inputbox by making a small form with a
single textbox and command button. The textbox would have it's Input Mask
property set to Password.

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top