Results 1 to 7 of 7
  1. #1
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66

    Exclamation How to Check 2 Data Entries to see if they are in the table

    Ok, the title doesn't really explain much. Here is my situation. I have a login form. 2 spots for users to input and ID and their name. I want to do error checking to see the user inputs a wrong name or wrong id with their corresponding name or ID. For example, I don't want User A to be able to login with User B's name. If User A inputs their ID and inputs User B's name, I want to show an error message stating the their is a mismatch of credentials. Here is my code

    Code:
    Private Sub Command12_Click()
    
    Dim rs As DAO.Recordset
    Dim txtID As Variant
    txtID = Forms![LoginForm2]![txtEmployeeID]
    txtName = Forms![LoginForm2]![Text13]
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM CoachTable WHERE EmployeeID = '" & txtID & "'", dbOpenDynaset)
    If Len(txtID) > 11 And Len(txtName) > 5 Then
    If rs.EOF Then 'no such person
      DoCmd.OpenForm "HourlyForm", acNormal
    Else
      DoCmd.OpenForm "frmMain", acNormal
    End If
    Else
    MsgBox "Please enter a valid Associate ID and/or Name"
    End If
    Exit Sub
    End Sub


  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Users must input name and ID?

    I would have users select name from combobox and input ID (assume noone knows each other's ID). Then check against table that the selected name and entered ID are a valid pairing.

    Do you have measures in place to prevent users from accessing the navigation pane? Are you aware that by holding down shift key when db opens, most startup options can be bypassed (unless this is an accde file)?
    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
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    I can't have IDs showing. That is why I have input boxes. I know there is a way to check those inputs against my table to see if they match the row of my table.

  4. #4
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    Yes I am aware. I have it locked down.

  5. #5
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    I would like the code to see if Name and ID are a valid pairing.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    So what is wrong with the code you already have? Step debug. Refer to link at bottom of my post for guidance on debug techniques.

    I did not say to show the IDs. Names in combobox, ID entered to textbox. Then:

    If IsNull(DLookup("ID", "CoachTable", "EmployeeID = '" & Me.txtID & "' AND EmployeeName='" & Me.combobox & "'")) Then
    MsgBox "This is not a valid login"
    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
    hammer187 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Aug 2012
    Posts
    66
    That seems it would work. Thanks.

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

Similar Threads

  1. Create multiple entries with same data
    By swavemeisterg in forum Forms
    Replies: 6
    Last Post: 05-30-2012, 10:16 AM
  2. Locking Entries in a Table
    By DDEB in forum Access
    Replies: 1
    Last Post: 05-23-2012, 02:14 PM
  3. Access VBA statement to check for Null entries
    By tim_tims33 in forum Access
    Replies: 4
    Last Post: 01-24-2012, 12:19 PM
  4. Can I link entries in a table?
    By ParishSec in forum Access
    Replies: 4
    Last Post: 09-27-2011, 10:04 AM
  5. How do I add multiple table entries using check boxes?
    By avarusbrightfyre in forum Access
    Replies: 3
    Last Post: 10-21-2010, 01:09 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