PC Review


Reply
Thread Tools Rate Thread

Capture User group log in

 
 
=?Utf-8?B?RnlzaA==?=
Guest
Posts: n/a
 
      29th Apr 2005
I have a DB using the User-Security Level which has just 3 groups. The
SuperAdmin, the RegAdmin, and the normal user. Currently when the program
starts up I have it set to display a form, which is hidden and runs some
procedures. However, it now needs to be changed to determine which group the
user belongs to when signing in. From the log-in I need to display a
separate form. For instance the RegAdmin needs to have a maintenance form
appear first, which the normal user will not have access to. How do I
capture which group the person signed as and then use this info to determine
which form is displayed first in the Starup under tools?

Thanks
 
Reply With Quote
 
 
 
 
Lynn Trapp
Guest
Posts: n/a
 
      29th Apr 2005
See section 22 of the Security FAQ. You can find a link to it on the
Security page of my website.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html


"Fysh" <(E-Mail Removed)> wrote in message
news:76BF2DED-FB7A-498B-BD38-(E-Mail Removed)...
>I have a DB using the User-Security Level which has just 3 groups. The
> SuperAdmin, the RegAdmin, and the normal user. Currently when the program
> starts up I have it set to display a form, which is hidden and runs some
> procedures. However, it now needs to be changed to determine which group
> the
> user belongs to when signing in. From the log-in I need to display a
> separate form. For instance the RegAdmin needs to have a maintenance form
> appear first, which the normal user will not have access to. How do I
> capture which group the person signed as and then use this info to
> determine
> which form is displayed first in the Starup under tools?
>
> Thanks



 
Reply With Quote
 
=?Utf-8?B?RnlzaA==?=
Guest
Posts: n/a
 
      29th Apr 2005
Ok I am confused. I read and re-read the information, but I am still
uncertain on how to invoke this. All I am trying to do is caputure the
log-in user name. Then when the program opens a hidden form will check to
see if they belong to this group, if so run this procedure and open this form
else run this other procedure and open a different form.
I saw this in one of the messages here and modified a little.


' Function: isMemberOfGrp( )
' Returns True if the user is in the group.
' Usage: isMemberOfGrp(CurrentUser(), "Admins")
'=======================================

Public Function isMemberOfGrp(sUserName As String, sGrpName As String)

On Error Resume Next

Dim memID As String

memID = DBEngine(0).Users(sUserName).Groups(sGrpName).Name

'-------------------------------------------------------------------
' Determine whether checking this Property
' caused an error or not.
'-------------------------------------------------------------------

If (Err.Number = 0) Then
isMemberOfGrp = True
Else
isMemberOfGrp = False
End If
End Function


Then onload event of the hidden form I have.

If isMemberOfGrp(CurrentUser(), "RegAdmin") Then
run this procedure blah blah
ElseIf isMemberOfGrp(CurrentUser(), "NormUser") Then
run this procedure blah blah
end if


"Lynn Trapp" wrote:

> See section 22 of the Security FAQ. You can find a link to it on the
> Security page of my website.
>
> --
> Lynn Trapp
> MS Access MVP
> www.ltcomputerdesigns.com
> Access Security: www.ltcomputerdesigns.com/Security.htm
> Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
>
>
> "Fysh" <(E-Mail Removed)> wrote in message
> news:76BF2DED-FB7A-498B-BD38-(E-Mail Removed)...
> >I have a DB using the User-Security Level which has just 3 groups. The
> > SuperAdmin, the RegAdmin, and the normal user. Currently when the program
> > starts up I have it set to display a form, which is hidden and runs some
> > procedures. However, it now needs to be changed to determine which group
> > the
> > user belongs to when signing in. From the log-in I need to display a
> > separate form. For instance the RegAdmin needs to have a maintenance form
> > appear first, which the normal user will not have access to. How do I
> > capture which group the person signed as and then use this info to
> > determine
> > which form is displayed first in the Starup under tools?
> >
> > Thanks

>
>
>

 
Reply With Quote
 
Jeff Conrad
Guest
Posts: n/a
 
      29th Apr 2005
"Fysh" wrote in message:
news:9C5E4A04-2041-45E0-8B0A-(E-Mail Removed)...

> Ok I am confused. I read and re-read the information, but I am still
> uncertain on how to invoke this. All I am trying to do is caputure the
> log-in user name. Then when the program opens a hidden form will check to
> see if they belong to this group, if so run this procedure and open this form
> else run this other procedure and open a different form.
> I saw this in one of the messages here and modified a little.


This sounds like a good place to use an AutoExec macro.

1. Copy/paste this code into a standard module (just overwrite
the function already there:

' Function: IsMemberOfGrp( )
' Returns True if the user is in the group.
' Usage: isMemberOfGrp(CurrentUser(), "Admins")
'=======================================

Public Function IsMemberOfGrp(sUserName As String, sGrpName As String)

On Error Resume Next

Dim strMemID As String

strMemID = DBEngine(0).Users(sUserName).Groups(sGrpName).Name
'-------------------------------------------------------------------
' Determine whether checking this Property
' caused an error or not.
'-------------------------------------------------------------------
If (Err.Number = 0) Then
IsMemberOfGrp = True
Else
IsMemberOfGrp = False
End If

End Function

2. Copy/paste this code into the same module if you prefer:

Public Function ShowCorrectForm()
On Error GoTo ErrorPoint

If IsMemberOfGrp(CurrentUser(), "RegAdmin") = True Then
' Run this procedure blah blah
' Open admin form
' DoCmd.OpenForm "frmAdmins"
ElseIf IsMemberOfGrp(CurrentUser(), "NormUser") = True Then
' Run this procedure blah blah
' Open regular user form
' DoCmd.OpenForm "frmUsers"
End If

ExitPoint:
Exit Function

ErrorPoint:
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Function

Adjust of course to run whatever you need it to.

3. Compile the code and save the module with a unique name
(basUtilities) or something.

4. Create a new macro. In the Action combo box select the option
called RunCode. in the Function name area near the bottom enter:
=ShowCorrectForm()

5. Save and close the macro with the name of Autoexec.
This will cause this code to run everytime the database starts,
unless of course you use the Shift key bypass.

Works just fine in my tests.
Hope that helps,

--
Jeff Conrad
Access Junkie
Bend, Oregon


 
Reply With Quote
 
=?Utf-8?B?RnlzaA==?=
Guest
Posts: n/a
 
      2nd May 2005
Sorry for the late reply. Thanks for the input, but I decided to include the
info on the hidden form on load event instead of a macro. I didn't have =
true part on the form which caused it not to work. Thanks again.

"Jeff Conrad" wrote:

> "Fysh" wrote in message:
> news:9C5E4A04-2041-45E0-8B0A-(E-Mail Removed)...
>
> > Ok I am confused. I read and re-read the information, but I am still
> > uncertain on how to invoke this. All I am trying to do is caputure the
> > log-in user name. Then when the program opens a hidden form will check to
> > see if they belong to this group, if so run this procedure and open this form
> > else run this other procedure and open a different form.
> > I saw this in one of the messages here and modified a little.

>
> This sounds like a good place to use an AutoExec macro.
>
> 1. Copy/paste this code into a standard module (just overwrite
> the function already there:
>
> ' Function: IsMemberOfGrp( )
> ' Returns True if the user is in the group.
> ' Usage: isMemberOfGrp(CurrentUser(), "Admins")
> '=======================================
>
> Public Function IsMemberOfGrp(sUserName As String, sGrpName As String)
>
> On Error Resume Next
>
> Dim strMemID As String
>
> strMemID = DBEngine(0).Users(sUserName).Groups(sGrpName).Name
> '-------------------------------------------------------------------
> ' Determine whether checking this Property
> ' caused an error or not.
> '-------------------------------------------------------------------
> If (Err.Number = 0) Then
> IsMemberOfGrp = True
> Else
> IsMemberOfGrp = False
> End If
>
> End Function
>
> 2. Copy/paste this code into the same module if you prefer:
>
> Public Function ShowCorrectForm()
> On Error GoTo ErrorPoint
>
> If IsMemberOfGrp(CurrentUser(), "RegAdmin") = True Then
> ' Run this procedure blah blah
> ' Open admin form
> ' DoCmd.OpenForm "frmAdmins"
> ElseIf IsMemberOfGrp(CurrentUser(), "NormUser") = True Then
> ' Run this procedure blah blah
> ' Open regular user form
> ' DoCmd.OpenForm "frmUsers"
> End If
>
> ExitPoint:
> Exit Function
>
> ErrorPoint:
> MsgBox "The following error has occurred:" _
> & vbNewLine & "Error Number: " & Err.Number _
> & vbNewLine & "Error Description: " & Err.Description _
> , vbExclamation, "Unexpected Error"
> Resume ExitPoint
>
> End Function
>
> Adjust of course to run whatever you need it to.
>
> 3. Compile the code and save the module with a unique name
> (basUtilities) or something.
>
> 4. Create a new macro. In the Action combo box select the option
> called RunCode. in the Function name area near the bottom enter:
> =ShowCorrectForm()
>
> 5. Save and close the macro with the name of Autoexec.
> This will cause this code to run everytime the database starts,
> unless of course you use the Shift key bypass.
>
> Works just fine in my tests.
> Hope that helps,
>
> --
> Jeff Conrad
> Access Junkie
> Bend, Oregon
>
>
>

 
Reply With Quote
 
Jeff Conrad
Guest
Posts: n/a
 
      2nd May 2005
"Fysh" wrote in message:
news:F7D36967-68A6-4193-8C6C-(E-Mail Removed)...

> Sorry for the late reply. Thanks for the input, but I decided to include the
> info on the hidden form on load event instead of a macro. I didn't have =
> true part on the form which caused it not to work. Thanks again.


No problem, glad you have it working now.
--
Jeff Conrad
Access Junkie
Bend, Oregon


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture a group of cells as an array Bythsx-Addagio Microsoft Excel Programming 1 29th Oct 2008 03:28 PM
HOW TO: capture the event when a row group is expanded or collapse =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV5?= Microsoft Excel Programming 0 4th Jul 2007 04:02 PM
Capture group addresses from e-mail =?Utf-8?B?QmlnIFdpbGx5?= Microsoft Outlook Contacts 1 11th May 2007 09:33 PM
question about RegEx group capture in C# Jose Microsoft C# .NET 2 8th Jan 2004 12:17 AM
How to capture the User authentication user name using Access 2000 Joel Microsoft Access 3 20th Sep 2003 12:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:03 PM.