Home All Groups Group Topic Archive Search About
Author
15 Apr 2009 2:12 PM
Alberta Rose
I have a switchboard with three buttons on it. I would like to password
protect one of the buttons because it is for administrator use only.  How do
I do this? 

Thanks.

Author
17 Apr 2009 4:28 AM
Tom van Stiphout
On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
<AlbertaR***@discussions.microsoft.com> wrote:

How strong do you want the protection to be? If minimal, how about
this one-liner in Form_Open event of that protected form (NOT the
button):
Cancel = (InputBox("Yo! Gimme your password") <> "secret")

-Tom.
Microsoft Access MVP



Show quoteHide quote
>I have a switchboard with three buttons on it. I would like to password
>protect one of the buttons because it is for administrator use only.  How do
>I do this? 
>
>Thanks.
Are all your drivers up to date? click for free checkup

Author
17 Apr 2009 5:40 PM
Jacqueline
Tom,
I tried this, but it did not work. I received an error message "The object
doesn't contain the Automation object 'Cancel'

I am using Access 2007, and this is exactly what I need to protect a few of
the reports in my database. My users are content with not understanding the
works of the db so don't explore as long as I make it pretty for them :)
However I do have a few reports that only one person should be able to
access. I think your advice is what I need if I can get it to work.
Thanks
Jacqueline

Show quoteHide quote
"Tom van Stiphout" wrote:

> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
> <AlbertaR***@discussions.microsoft.com> wrote:
>
> How strong do you want the protection to be? If minimal, how about
> this one-liner in Form_Open event of that protected form (NOT the
> button):
> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
>
> -Tom.
> Microsoft Access MVP
>
>
>
> >I have a switchboard with three buttons on it. I would like to password
> >protect one of the buttons because it is for administrator use only.  How do
> >I do this? 
> >
> >Thanks.
>
Author
17 Apr 2009 8:32 PM
Afrosheen via AccessMonster.com
Hi Jacqueline. It's a pleasure to finally get to help someone after all the
help I've gotten here. This is a program I've been using. It takes the
password and stores the information in another table so you can see who's
been in there. Here are the stats.

Create a new form call it: frmPass

On the form Record Source select tblPass

Create an Unbound text box and name it: username. Input Mask: Password. Note
The text for the username would be UserID:

Create another Unbound text box and name it:Pword.  Inpaut Mask: Password.
Note: Name the text: Password:

Create two tables:
Table 1
tblPass
Key: AutoNnumber
User: Text
Password: Text
UserLevel: Number
Name: Text

Table 2
tblPassLog
Id: AutoNumber
Date: Date/Time
Time: Date/Time
User: Text
Uname: Text
PrgName: Text

Now, Here is the code:

Private Sub Pword_AfterUpdate()
      Dim pname As String
      Dim I As Integer
      Dim rst As DAO.Recordset  ' The tLogError table
10    strUser = username

      Static counter As Integer
20    If StrComp(Me.Pword, Nz(DLookup("Password", "tblpass", "User=" & """" &
strUser & """"), ""), 0) = 0 Then
30       userpermission = DLookup("[userlevel]", "[tblpass]", "[User] = '" &
strUser & "'")
40       pname = DLookup("[name]", "[tblpass]", "[User] = '" & strUser & "'")
50       If userpermission = 3 Then
60           Call MsgBox("Your security level is not high enough to continue.
", vbCritical, "Access Denied")
70           DoCmd.Close acForm, "frmpass"
80       Exit Sub
90       Else
100          strUser = ""
110          username = ""
120          Pword = ""
130      End If

140       Set rst = CurrentDb.OpenRecordset("tPassLog", , dbAppendOnly)
150        rst.AddNew
160        rst![Date] = Date
170        rst![User] = strUser
180        rst![Time] = Time()
190        rst![Uname] = pname
200        rst![prgname] = "FrmPass"
210        rst.Update
220        rst.Close

230   DoCmd.Close acForm, "frmpass"  'Closes the password window

       ' ***************** Show or Hide the Table Window ***************
        'To show the database window, run
240       DoCmd.SelectObject acTable, , True

        'To Hide the database window, run
           'DoCmd.SelectObject acTable, , True
           'DoCmd.RunCommand acCmdWindowHide

250   For I = 1 To CommandBars.Count
260   CommandBars(I).Enabled = True
270   Next I

280        DoCmd.Close acForm, "Your form you want to close"
290        Exit Sub

300   Else
310     If counter < 2 Then
320       Call MsgBox("Oh Oh! You Didn't Say the Magic Word!!" _
                      & vbCrLf & "" _
                      & vbCrLf & "You Only Get 3 Times To Get It Right" _
                      , vbCritical, Application.Name)

330       strUser = ""
340       username = ""
350       Pword = ""
360       counter = counter + 1
370     Else
380       DoCmd.Close acForm, "Your Form Name"
390     End If
400   End If

End Sub


What this will do is check the user level of the program and close the
program. Then store the information in the pass log table.

Good Luck. Let me know if it works for you.



Jacqueline wrote:
Show quoteHide quote
>Tom,
>I tried this, but it did not work. I received an error message "The object
>doesn't contain the Automation object 'Cancel'
>
>I am using Access 2007, and this is exactly what I need to protect a few of
>the reports in my database. My users are content with not understanding the
>works of the db so don't explore as long as I make it pretty for them :)
>However I do have a few reports that only one person should be able to
>access. I think your advice is what I need if I can get it to work.
>Thanks
>Jacqueline
>
>> How strong do you want the protection to be? If minimal, how about
>> this one-liner in Form_Open event of that protected form (NOT the
>[quoted text clipped - 9 lines]
>> >
>> >Thanks.

Author
17 Apr 2009 9:32 PM
Jacqueline
Thanks, this looks scary, but I will work through it. I will let you know if
it work... :)
Jacqueline

Show quoteHide quote
"Afrosheen via AccessMonster.com" wrote:

> Hi Jacqueline. It's a pleasure to finally get to help someone after all the
> help I've gotten here. This is a program I've been using. It takes the
> password and stores the information in another table so you can see who's
> been in there. Here are the stats.
>
> Create a new form call it: frmPass
>
> On the form Record Source select tblPass
>
> Create an Unbound text box and name it: username. Input Mask: Password. Note
> The text for the username would be UserID:
>
> Create another Unbound text box and name it:Pword.  Inpaut Mask: Password.
> Note: Name the text: Password:
>
> Create two tables:
> Table 1
> tblPass
> Key: AutoNnumber
> User: Text
> Password: Text
> UserLevel: Number
> Name: Text
>
> Table 2
> tblPassLog
> Id: AutoNumber
> Date: Date/Time
> Time: Date/Time
> User: Text
> Uname: Text
> PrgName: Text
>
> Now, Here is the code:
>
> Private Sub Pword_AfterUpdate()
>       Dim pname As String
>       Dim I As Integer
>       Dim rst As DAO.Recordset  ' The tLogError table
> 10    strUser = username
>      
>       Static counter As Integer
> 20    If StrComp(Me.Pword, Nz(DLookup("Password", "tblpass", "User=" & """" &
> strUser & """"), ""), 0) = 0 Then
> 30       userpermission = DLookup("[userlevel]", "[tblpass]", "[User] = '" &
> strUser & "'")
> 40       pname = DLookup("[name]", "[tblpass]", "[User] = '" & strUser & "'")
> 50       If userpermission = 3 Then
> 60           Call MsgBox("Your security level is not high enough to continue.
> ", vbCritical, "Access Denied")
> 70           DoCmd.Close acForm, "frmpass"
> 80       Exit Sub
> 90       Else
> 100          strUser = ""
> 110          username = ""
> 120          Pword = ""
> 130      End If
>          
> 140       Set rst = CurrentDb.OpenRecordset("tPassLog", , dbAppendOnly)
> 150        rst.AddNew
> 160        rst![Date] = Date
> 170        rst![User] = strUser
> 180        rst![Time] = Time()
> 190        rst![Uname] = pname
> 200        rst![prgname] = "FrmPass"
> 210        rst.Update
> 220        rst.Close
>
> 230   DoCmd.Close acForm, "frmpass"  'Closes the password window
>        
>        ' ***************** Show or Hide the Table Window ***************
>         'To show the database window, run
> 240       DoCmd.SelectObject acTable, , True
>
>         'To Hide the database window, run
>            'DoCmd.SelectObject acTable, , True
>            'DoCmd.RunCommand acCmdWindowHide
>        
> 250   For I = 1 To CommandBars.Count
> 260   CommandBars(I).Enabled = True
> 270   Next I
>      
> 280        DoCmd.Close acForm, "Your form you want to close"
> 290        Exit Sub
>
> 300   Else
> 310     If counter < 2 Then
> 320       Call MsgBox("Oh Oh! You Didn't Say the Magic Word!!" _
>                       & vbCrLf & "" _
>                       & vbCrLf & "You Only Get 3 Times To Get It Right" _
>                       , vbCritical, Application.Name)
>          
> 330       strUser = ""
> 340       username = ""
> 350       Pword = ""
> 360       counter = counter + 1
> 370     Else
> 380       DoCmd.Close acForm, "Your Form Name"
> 390     End If
> 400   End If
>
> End Sub
>
>
> What this will do is check the user level of the program and close the
> program. Then store the information in the pass log table.
>
> Good Luck. Let me know if it works for you.
>
>
>
> Jacqueline wrote:
> >Tom,
> >I tried this, but it did not work. I received an error message "The object
> >doesn't contain the Automation object 'Cancel'
> >
> >I am using Access 2007, and this is exactly what I need to protect a few of
> >the reports in my database. My users are content with not understanding the
> >works of the db so don't explore as long as I make it pretty for them :)
> >However I do have a few reports that only one person should be able to
> >access. I think your advice is what I need if I can get it to work.
> >Thanks
> >Jacqueline
> >
> >> How strong do you want the protection to be? If minimal, how about
> >> this one-liner in Form_Open event of that protected form (NOT the
> >[quoted text clipped - 9 lines]
> >> >
> >> >Thanks.
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-security/200904/1
>
>
Author
18 Apr 2009 1:16 AM
Afrosheen via AccessMonster.com
Hi Jacqueline,

Don't let it scare you just change the fields you need to change. If I can
help just reply to the post. What I"ve found handy is the Copy/Paste. Then
see if it works. Be aware this is just a simple program. If you want total
security then you'll have to use the Access program it's self.

Note: You will have to assign passwords and user levels.

I haven't found any password type forms for entering passwords, userlevels,
and UserIDs. I'll keep looking.



Jacqueline wrote:
>Thanks, this looks scary, but I will work through it. I will let you know if
>it work... :)
>Jacqueline
>
>> Hi Jacqueline. It's a pleasure to finally get to help someone after all the
>> help I've gotten here. This is a program I've been using. It takes the
>[quoted text clipped - 121 lines]
>> >> >
>> >> >Thanks.

Author
18 Apr 2009 3:46 PM
Tom van Stiphout
On Fri, 17 Apr 2009 10:40:01 -0700, Jacqueline
<Jacquel***@discussions.microsoft.com> wrote:

I am in A2007 too, although that does not matter for this situation.
The error tells me you were not in the Form_Open event. Please check
again, or post your code.

Private Sub Form_Open(Cancel As Integer)
    Cancel = (InputBox("Yo! Gimme your password") <> "secret")
End Sub

-Tom.
Microsoft Access MVP


Show quoteHide quote
>Tom,
>I tried this, but it did not work. I received an error message "The object
>doesn't contain the Automation object 'Cancel'
>
>I am using Access 2007, and this is exactly what I need to protect a few of
>the reports in my database. My users are content with not understanding the
>works of the db so don't explore as long as I make it pretty for them :)
>However I do have a few reports that only one person should be able to
>access. I think your advice is what I need if I can get it to work.
>Thanks
>Jacqueline
>
>"Tom van Stiphout" wrote:
>
>> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
>> <AlbertaR***@discussions.microsoft.com> wrote:
>>
>> How strong do you want the protection to be? If minimal, how about
>> this one-liner in Form_Open event of that protected form (NOT the
>> button):
>> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
>>
>> -Tom.
>> Microsoft Access MVP
>>
>>
>>
>> >I have a switchboard with three buttons on it. I would like to password
>> >protect one of the buttons because it is for administrator use only.  How do
>> >I do this? 
>> >
>> >Thanks.
>>
Author
20 Apr 2009 4:18 PM
Jacqueline
Tom,
You were correct, I had the code in the wrong place. I was trying to use the
reports properties event, rather than VB Report_Open. It works now thanks
Jacqueline

Show quoteHide quote
"Tom van Stiphout" wrote:

> On Fri, 17 Apr 2009 10:40:01 -0700, Jacqueline
> <Jacquel***@discussions.microsoft.com> wrote:
>
> I am in A2007 too, although that does not matter for this situation.
> The error tells me you were not in the Form_Open event. Please check
> again, or post your code.
>
> Private Sub Form_Open(Cancel As Integer)
>     Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> End Sub
>
> -Tom.
> Microsoft Access MVP
>
>
> >Tom,
> >I tried this, but it did not work. I received an error message "The object
> >doesn't contain the Automation object 'Cancel'
> >
> >I am using Access 2007, and this is exactly what I need to protect a few of
> >the reports in my database. My users are content with not understanding the
> >works of the db so don't explore as long as I make it pretty for them :)
> >However I do have a few reports that only one person should be able to
> >access. I think your advice is what I need if I can get it to work.
> >Thanks
> >Jacqueline
> >
> >"Tom van Stiphout" wrote:
> >
> >> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
> >> <AlbertaR***@discussions.microsoft.com> wrote:
> >>
> >> How strong do you want the protection to be? If minimal, how about
> >> this one-liner in Form_Open event of that protected form (NOT the
> >> button):
> >> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> >>
> >> -Tom.
> >> Microsoft Access MVP
> >>
> >>
> >>
> >> >I have a switchboard with three buttons on it. I would like to password
> >> >protect one of the buttons because it is for administrator use only.  How do
> >> >I do this? 
> >> >
> >> >Thanks.
> >>
>
Author
20 Apr 2009 7:11 PM
Alberta Rose
Hi Tom.  Here is the coding for the button I want to protect.  Where in it
should I add the coding as you suggested.

Your Suggestion:

Private Sub Form_Open(Cancel As Integer)
Cancel = (InputBox("Yo! Gimme your password") <> "secret")
End Sub


My Buttons Coding:

Private Sub cmdForms_Click()
On Error GoTo Err_cmdForms_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmInput"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdForms_Click:
    Exit Sub

Err_cmdForms_Click:
    MsgBox Err.Description
    Resume Exit_cmdForms_Click

End Sub

Show quoteHide quote
"Tom van Stiphout" wrote:

> On Fri, 17 Apr 2009 10:40:01 -0700, Jacqueline
> <Jacquel***@discussions.microsoft.com> wrote:
>
> I am in A2007 too, although that does not matter for this situation.
> The error tells me you were not in the Form_Open event. Please check
> again, or post your code.
>
> Private Sub Form_Open(Cancel As Integer)
>     Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> End Sub
>
> -Tom.
> Microsoft Access MVP
>
>
> >Tom,
> >I tried this, but it did not work. I received an error message "The object
> >doesn't contain the Automation object 'Cancel'
> >
> >I am using Access 2007, and this is exactly what I need to protect a few of
> >the reports in my database. My users are content with not understanding the
> >works of the db so don't explore as long as I make it pretty for them :)
> >However I do have a few reports that only one person should be able to
> >access. I think your advice is what I need if I can get it to work.
> >Thanks
> >Jacqueline
> >
> >"Tom van Stiphout" wrote:
> >
> >> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
> >> <AlbertaR***@discussions.microsoft.com> wrote:
> >>
> >> How strong do you want the protection to be? If minimal, how about
> >> this one-liner in Form_Open event of that protected form (NOT the
> >> button):
> >> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> >>
> >> -Tom.
> >> Microsoft Access MVP
> >>
> >>
> >>
> >> >I have a switchboard with three buttons on it. I would like to password
> >> >protect one of the buttons because it is for administrator use only.  How do
> >> >I do this? 
> >> >
> >> >Thanks.
> >>
>
Author
20 Apr 2009 7:29 PM
Jacqueline
Hi Alberta,
This came to me not Tom, however I think I can answer your question. My
report is also accessed from a button, but I did not protect the button, I
protected the report.

If you open your report in design view, click on the VIEW CODE tool, either
on the design tab or if you are not in 2007 I believe it is in your Tools
menu.

With the VB Code window open, paste in the following code from Tom:

Private Sub Report_Open(Cancel As Integer)
Cancel = (InputBox("Please enter  your password") <> "your password here")
End Sub

close the code window.

Anyone can access the button, however if they do nto have the password they
will not be able to access the report, or form... depending on where you are
using this.
Hope this helps, if not be sure to reply to Tom so he will get the email. :)
Jacqueline


Show quoteHide quote
"Alberta Rose" wrote:

> Hi Tom.  Here is the coding for the button I want to protect.  Where in it
> should I add the coding as you suggested.
>
> Your Suggestion:
>
> Private Sub Form_Open(Cancel As Integer)
> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> End Sub
>
>
> My Buttons Coding:
>
> Private Sub cmdForms_Click()
> On Error GoTo Err_cmdForms_Click
>
>     Dim stDocName As String
>     Dim stLinkCriteria As String
>
>     stDocName = "frmInput"
>     DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> Exit_cmdForms_Click:
>     Exit Sub
>
> Err_cmdForms_Click:
>     MsgBox Err.Description
>     Resume Exit_cmdForms_Click
>    
> End Sub
>
> "Tom van Stiphout" wrote:
>
> > On Fri, 17 Apr 2009 10:40:01 -0700, Jacqueline
> > <Jacquel***@discussions.microsoft.com> wrote:
> >
> > I am in A2007 too, although that does not matter for this situation.
> > The error tells me you were not in the Form_Open event. Please check
> > again, or post your code.
> >
> > Private Sub Form_Open(Cancel As Integer)
> >     Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> > End Sub
> >
> > -Tom.
> > Microsoft Access MVP
> >
> >
> > >Tom,
> > >I tried this, but it did not work. I received an error message "The object
> > >doesn't contain the Automation object 'Cancel'
> > >
> > >I am using Access 2007, and this is exactly what I need to protect a few of
> > >the reports in my database. My users are content with not understanding the
> > >works of the db so don't explore as long as I make it pretty for them :)
> > >However I do have a few reports that only one person should be able to
> > >access. I think your advice is what I need if I can get it to work.
> > >Thanks
> > >Jacqueline
> > >
> > >"Tom van Stiphout" wrote:
> > >
> > >> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
> > >> <AlbertaR***@discussions.microsoft.com> wrote:
> > >>
> > >> How strong do you want the protection to be? If minimal, how about
> > >> this one-liner in Form_Open event of that protected form (NOT the
> > >> button):
> > >> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> > >>
> > >> -Tom.
> > >> Microsoft Access MVP
> > >>
> > >>
> > >>
> > >> >I have a switchboard with three buttons on it. I would like to password
> > >> >protect one of the buttons because it is for administrator use only.  How do
> > >> >I do this? 
> > >> >
> > >> >Thanks.
> > >>
> >
Author
20 Apr 2009 8:00 PM
Alberta Rose
Hi Tom. Here is the coding for the button I want to protect. Where in it
should I add the coding as you suggested.

Your Suggestion:

Private Sub Form_Open(Cancel As Integer)
Cancel = (InputBox("Yo! Gimme your password") <> "secret")
End Sub


My Buttons Coding:

Private Sub cmdForms_Click()
On Error GoTo Err_cmdForms_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInput"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdForms_Click:
Exit Sub

Err_cmdForms_Click:
MsgBox Err.Description
Resume Exit_cmdForms_Click

End Sub



Show quoteHide quote
"Tom van Stiphout" wrote:

> On Fri, 17 Apr 2009 10:40:01 -0700, Jacqueline
> <Jacquel***@discussions.microsoft.com> wrote:
>
> I am in A2007 too, although that does not matter for this situation.
> The error tells me you were not in the Form_Open event. Please check
> again, or post your code.
>
> Private Sub Form_Open(Cancel As Integer)
>     Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> End Sub
>
> -Tom.
> Microsoft Access MVP
>
>
> >Tom,
> >I tried this, but it did not work. I received an error message "The object
> >doesn't contain the Automation object 'Cancel'
> >
> >I am using Access 2007, and this is exactly what I need to protect a few of
> >the reports in my database. My users are content with not understanding the
> >works of the db so don't explore as long as I make it pretty for them :)
> >However I do have a few reports that only one person should be able to
> >access. I think your advice is what I need if I can get it to work.
> >Thanks
> >Jacqueline
> >
> >"Tom van Stiphout" wrote:
> >
> >> On Wed, 15 Apr 2009 07:12:08 -0700, Alberta Rose
> >> <AlbertaR***@discussions.microsoft.com> wrote:
> >>
> >> How strong do you want the protection to be? If minimal, how about
> >> this one-liner in Form_Open event of that protected form (NOT the
> >> button):
> >> Cancel = (InputBox("Yo! Gimme your password") <> "secret")
> >>
> >> -Tom.
> >> Microsoft Access MVP
> >>
> >>
> >>
> >> >I have a switchboard with three buttons on it. I would like to password
> >> >protect one of the buttons because it is for administrator use only.  How do
> >> >I do this? 
> >> >
> >> >Thanks.
> >>
>

Bookmark and Share