Username needed to access switchboard items

breadcrumbtrail

Registered User.
Local time
Today, 23:55
Joined
Mar 25, 2004
Messages
16
Hi there!

Is it possible for me to request a username and/or password before a user can click on a certain button in an access database? The reason being I have been assigned to create an end-user database, but have buttons regarding staff-only actions which I wouldn't want customers using. I don't really want the whole database itself password protected, just these individual items. Any help will be greatly appreciated!

Many Thanks

- John
 
breadcrumbtrail said:
Hi there!

Is it possible for me to request a username and/or password before a user can click on a certain button in an access database? The reason being I have been assigned to create an end-user database, but have buttons regarding staff-only actions which I wouldn't want customers using. I don't really want the whole database itself password protected, just these individual items. Any help will be greatly appreciated!

Many Thanks

- John

Search the forum.

There are a number of solutions to this request and it has been asked and answered loads
There are various examples as well as solutions including an example of how to password control items via a button.

The search routine is accessed via a button on the top title block
 
I would suggest that you use the built in Access security to lock down your db so that you can decide who can access which objects [forms, reports, etc] you want them to and more importantly prevent anybody from linking to your db and or import you database objects [tables, modules, etc] to another database.

Since it sounds like you do not care if somebody can acess your data externally then you have a couple of choices. You can create a password verification form so that the user has to input the correct user name and password which is stored in a table. Or you can cheaply and quickly add a function to the OnClick event of your buttons to force the user to input the correct password into an Input Box if they want to access [open a form, report, etc]. You can search this forum for examples of all of the above. The code below will show you how to use the latter of my suggestions...
Code:
    Dim strInput As String
    Dim strMsg As String
    
    Beep
    strMsg = "This form is used only by the ''Special Form'' people." & vbCrLf & vbLf & "Please key the ''Special Form'' password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Special Password")
    If strInput = "SpecialFormPassword" Then 'password is correct
        DoCmd.OpenForm "YourSpecialFormNameHere"
        DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
        MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''Special Form''.", vbCritical, "Invalid Password"
        Exit Sub
    End If
You can not format an Input Box. You will have to create a custom form if you want the hide the password with **********.

The above is a simple way to call an input box that allows the user to key a password and if correct it will open a form. Assign the code to the OnClick event of the button to open the form that you want password protected.
 
Hi, thanks for your reply.

I have created my switchboard using switchboard manager. And I'm a complete Access n00b, so I'm a bit slow on the uptake when it comes to all this... When I right click on Switchboard in my forms list, and go to design view, there are a number of buttons and no text there, so I'm not actually sure which button I should apply the code to. Basically I have 3 buttons on the main switchboard, one option to go to the customer section and one to go to the staff section, and a third to exit the database. But because when I open it in design view there are more than 3 buttons, i'm not sure which button is which. Is there another way to enter this code?

Many thanks,

- John
 
breadcrumbtrail said:
I have created my switchboard using switchboard manager.
Ditch the switchboard you created with the wizard and create your own main menu form [with your own command buttons] for your users to navigate through out your database.
 
ghudson said:
Ditch the switchboard you created with the wizard and create your own main menu form [with your own command buttons] for your users to navigate through out your database.

I'm really not confident enough with my ability in access or as a programmer to design one from scratch, and with the timescale available, its going to be very difficult. If there is anyway to define a password from the switchboard manager, then I will glady use that over desigining a whole new switchboard! Is there a way I can do it using a macro?

Many Thanks,

- John
 
ghudson already provided you with the most adequate reply. Yes, it's VBA code and you may be weary but there really is no other way around it; No "Access" related option. You can search for more examples or help files with InputBox if you want to understand it more.

Good luck!
 
I have an additional question regarding the Switchboard. My db is secured using the built in MS security. If a user who don't have access to a form, tries to open it, an error message appears - saying 'There was an error executing the command'. It should have read something like 'You don't have permission to use....' Is there some way to prevent the error message to be displayed, or change it?

TIA
 
geralf said:
If a user who don't have access to a form, tries to open it, an error message appears - saying 'There was an error executing the command'.TIA
You should hide or disable the button based on the current user. Use the forms OnOpen event and test for which users you want to display or enable the buttons based on the current user.

If CurrentUser = "John" Then
btnForm1.Visible = True
Else
btnForm1.Visible = False
End If
 
Hi Greg!

Thanks for your reply, but I don't find the solution very good, since I've then have to code the user names some way, and test accordingly. I would rather that Access some way checked the permissions the user has, and opened the form or displayed a message 'You don't have permission.....'. This might be to much to ask for, so then we're stuck with some workaround. I told the users that the error message is because they don't have permission, so just click the OK button to continue. Works OK that also, but it would seem more proper to be warned of missing permissions than the error message.
 

Users who are viewing this thread

Back
Top Bottom