Results 1 to 8 of 8
  1. #1
    Zantox is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Cyberspace
    Posts
    4

    Multi User Logon: Check Box = Diffrent Forms

    Hello Everyone.
    I have set up a Mutli-User Logon for one of my databases, the code for it now is as follows:
    Code:
    Option Compare Database
      Private intLogonAttempts As Integer
    Private Sub buttonlogin_Click()
      'Check to see if data is entered into the UserName combo box
        If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
            MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.cboEmployee.SetFocus
          Exit Sub
        End If
      'Check to see if data is entered into the password box
        If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
            MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
            Me.txtPassword.SetFocus
          Exit Sub
        End If
      'Check value of password in tblEmployees to see if this matches value chosen in combo box
        If Me.txtPassword.Value = DLookup("Password", "users", "ID=" & Me.cboEmployee.Value) Then
          MyEmpID = Me.cboEmployee.Value
      'Close logon form and open splash screen
          DoCmd.Close acForm, "login", acSaveNo
          DoCmd.OpenForm "user_cp"
          Else
          MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
          Me.txtPassword.SetFocus
        End If
      'If User Enters incorrect password 3 times database will shutdown
        intLogonAttempts = intLogonAttempts + 1
        If intLogonAttempts > 3 Then
          MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
          Application.Quit
        End If
    End Sub
    Which works Great!

    I have added a colum to the "user" table with a check box in it, and added a check box to the "login" form called "admincheck". If it is checked I would like it to open "admin_cp" on login rather then "user_cp".

    What is the best way to do this? Code would be greatly appreciated!

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Include the admincheck field in the cboEmployee RowSource then it is available for reference. Combobox column index begins with 0 so if the checkfield is in column2, the index is 1. After the login is verified:

    DoCmd.OpenForm IIf(cboEmployee.Column(1), "admin_cp", "user_cp")
    DoCmd.Close acForm, "login", acSaveNo
    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
    Zantox is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Cyberspace
    Posts
    4
    Quote Originally Posted by June7 View Post
    Include the admincheck field in the cboEmployee RowSource then it is available for reference. Combobox column index begins with 0 so if the checkfield is in column2, the index is 1. After the login is verified:

    DoCmd.OpenForm IIf(cboEmployee.Column(1), "admin_cp", "user_cp")
    DoCmd.Close acForm, "login", acSaveNo
    Wow thanks,
    Would you mind breaking that down a little bit more, if you can tho, I'm a little stupid sometimes?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Review this tutorial about multi-column combobox http://datapigtechnologies.com/flash...combobox3.html
    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
    Zantox is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Cyberspace
    Posts
    4
    Quote Originally Posted by June7 View Post
    Review this tutorial about multi-column combobox http://datapigtechnologies.com/flash...combobox3.html
    that didn't help me
    My Table is set up as:

    ID | Username | Password | Admin | Position |

    would it be possible to just get raw code and where to put it.
    I'm not sure what a "cBOEmployee Rowsource" is?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If you built a combobox you must have set the RowSource property. The RowSource is where you define the list of items for the combobox.

    Why did the tutorial not help? You already have the combobox cboEmployee on form, why not take advantage of its features? It's really the simpler approach. Multi-column comboboxes are very useful. You should be familiar with their structure.

    Otherwise try DLookup() function:

    DoCmd.OpenForm IIf(DLookup("admincheck", "user", "ID=" & Me.cboEmployee) = True, "admin_cp", "user_cp")
    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.

  7. #7
    Zantox is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Cyberspace
    Posts
    4
    Quote Originally Posted by June7 View Post
    If you built a combobox you must have set the RowSource property. The RowSource is where you define the list of items for the combobox.

    Why did the tutorial not help? You already have the combobox cboEmployee on form, why not take advantage of its features? It's really the simpler approach. Multi-column comboboxes are very useful. You should be familiar with their structure.

    Otherwise try DLookup() function:

    DoCmd.OpenForm IIf(DLookup("admincheck", "user", "ID=" & Me.cboEmployee) = True, "admin_cp", "user_cp")
    This still dosen't tell me where to put the code.
    It would be a lot simplier if you could just take my code from the original post, add the above stuff accordingly and make it red so I can see where the chages occoured and then paste it into the compiler.
    I don't mean to be a bother, that is just the easiest way for me.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yes it does. Just replace the .OpenForm and .Close lines in your code with my suggestions, in the order I show.
    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.

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

Similar Threads

  1. Multi-User Log in
    By iky123 in forum Access
    Replies: 1
    Last Post: 04-16-2012, 10:59 AM
  2. multi user
    By crapbutaddicted in forum Access
    Replies: 3
    Last Post: 03-23-2012, 08:56 AM
  3. Replies: 0
    Last Post: 09-27-2011, 12:25 PM
  4. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  5. Replies: 12
    Last Post: 06-16-2011, 01:35 PM

Tags for this Thread

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