Results 1 to 4 of 4
  1. #1
    KEBUNGO is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2018
    Posts
    2

    Validate a user before a form loads - after login

    A student posed a question: How to control access to forms after a user successfully logs into the system. The database that was designed is attached here.



    TempVars("UserType") = rs!UserTypeID.Value captures the ID of the user logged in. (LOGIN FORM)

    This code:

    Private Sub Form_Load()

    If Nz(DLookup("HasAccess", "tblUserAccess", "UserTypeID = " & TempVars("UserType") & " AND FormName = ' " & Me.Name & " ' "), False) = False Then

    MsgBox "You do not have access"
    DoCmd.Close acForm, Me.Name

    End If

    End Sub

    is attached to the frmOrderApproval form.

    unfortunately, all users are denied access to this form. help me to debug this code.




  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    you seem to have additional spaces


    FormName = ' " & Me.Name & " ' "

    should be

    FormName = '" & Me.Name & "'"

  4. #4
    KEBUNGO is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2018
    Posts
    2
    Thanks Ajax, your suggestion solved my problem. I had not forseen that the additional spaces was an issue in this code. Thanks Orange for replying to my query.

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

Similar Threads

  1. Login user show on form
    By AccessThomas in forum Access
    Replies: 3
    Last Post: 05-11-2016, 12:14 PM
  2. Multi user login form
    By an1bone in forum Access
    Replies: 3
    Last Post: 08-03-2015, 12:58 PM
  3. Replies: 5
    Last Post: 03-02-2014, 12:37 PM
  4. Login Form/User ID Trouble.
    By Addanny in forum Forms
    Replies: 2
    Last Post: 07-03-2013, 10:25 AM
  5. User Login Form
    By glen in forum Forms
    Replies: 21
    Last Post: 09-17-2012, 09:09 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