Results 1 to 5 of 5
  1. #1
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727

    button access

    all. I have a form with buttons to access forms. I don't want a certain group of users to access this form. I have a login form with user name password and dept. Upon successful password; the user can access the switchboard which has three buttons to gain access to another form. I tried using a dlookup:

    Code:
    Dim strDept As String
    
    If strDept = DLookup("strEmpName", "tblUsers", "strDept="HR" )Then
    msgbox "you don't have access"
    Besides the problem that this code doesn't work; the login form is closed by the time the user clicks the button. This is why i didn't reference the form (Forms!frmLogon!cboEmployee) in the code.


    Help please
    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    One solution is to store the user login information - either the dept or username or both - someplace where code can refer to it at any time. I do this by populating textbox on a 'Main Menu' form that never closes. Then code could reference that form textbox.

    Another option is a Global/Public declared variable. Problem with this is when debugging if code execution is interrupted the variable loses its value.

    Otherwise, you have to pull their username from the network every time you need to check user authorizations.

    If DLookup("strDept", "tblUsers", "UserName='" & Environ("USERNAME") & "'") = "HR" Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    what if I hide the logon form instead of closing it. Then I can refer to it in the button code. Do you think this would work?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Yes, a hidden form can still be referenced.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    slimjen is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Posts
    727
    Got it. Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to code in AddNew Button In Access DBA
    By ganeshvenkatram in forum Access
    Replies: 0
    Last Post: 07-07-2011, 02:50 AM
  2. Submit button in access form
    By Melo in forum Forms
    Replies: 2
    Last Post: 09-25-2010, 08:37 AM
  3. Access Options Button
    By 95DSM in forum Programming
    Replies: 1
    Last Post: 08-16-2010, 03:05 PM
  4. Replies: 1
    Last Post: 06-20-2010, 05:04 AM
  5. Net Send from a button on an Access form
    By Deb4995 in forum Forms
    Replies: 0
    Last Post: 10-19-2006, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums