Results 1 to 5 of 5
  1. #1
    jaymin is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jan 2012
    Location
    gold coast Australia
    Posts
    57

    getting a button control to lookup a table to verify a txt control entry is in table

    Hope someone can help
    I have a password form which has two txt boxes one for username entry and password entry, plus two buttons "close" and "enter password". i have a table called tblPassword , what i want to happen is that when the "enter Password" button is pressed it looks for the name that was entered in the "username" txt in the table, then
    compares it to the password entered in the "Password " txt if there is a match do what ever.

    Peter

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Where:
    • Password and UserName are Fields in the tblPassword Table
    • txtPassword and txtUserName are Controls on your Form
    • btnSubmitPassword is the Command Button

    Code:
    Private Sub btnSubmitPassword_Click()
    
    If Me.txtPassword = DLookup("Password", "tblPassword", "[UserName] = '" & Me.txtUserName & "'") Then
      'Do whatever you want if Password is correct
    Else
      MsgBox "Password Submitted Does Not Match User Name!"
    End If
    
    End Sub


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    jaymin is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jan 2012
    Location
    gold coast Australia
    Posts
    57
    Missinglinq,
    Thank you for your easy to understand instructions and a quick reply. I have it working.
    Thanks again for your time and help with this matter.

    Peter

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    jaymin is offline Advanced Beginner
    Windows Vista Access 2003
    Join Date
    Jan 2012
    Location
    gold coast Australia
    Posts
    57
    Missinglinq,
    sorry if i am going around this the wrong way but your help was great.
    Another DLookup problem for me that is, i have tried to transpose the code you gave me, but my understanding of it has left me.
    i have a form with a txt box txtChipNumber it is attached to the after update event, the field in the the table i want to look up is chipnumber from the table tblPPE, the code i am using is this,
    Me.txtChipNumber = DLookup("ChipNumber", "tblPPE", "[ChipNumber]='txtChipNumber'")
    This is the sub i use
    Private Sub txtChipNumber_AfterUpdate()
    If Me.txtChipNumber = DLookup("ChipNumber", "tblPPE", "[ChipNumber]='txtChipNumber'") Then
    MsgBox ("this number taken")
    Else
    MsgBox ("this number not taken")
    Me.cboGarmentType.Enabled = True
    Me.cboGarmentType.SetFocus

    End If
    End Sub
    I changed the code to this below it now works fine, once again thanks for your help, i would not be able to do it not for your kind help
    Me.txtChipNumber = DLookup("ChipNumber", "tblPPE", "[ChipNumber]='" & txtChipNumber & "'")
    once again i will Apologise if i am doing anything wrong
    Peter
    Last edited by jaymin; 06-30-2012 at 02:23 AM. Reason: found solution

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

Similar Threads

  1. Replies: 2
    Last Post: 02-20-2012, 10:18 PM
  2. Get value from other control not updating table
    By 1eye1vision in forum Access
    Replies: 3
    Last Post: 02-08-2012, 05:37 PM
  3. writing control names on a form to a table
    By focosi in forum Access
    Replies: 1
    Last Post: 09-21-2011, 08:47 AM
  4. Lookup List in a Form for Table Record entry...
    By noaccessguru in forum Forms
    Replies: 1
    Last Post: 05-05-2011, 12:35 AM
  5. Replies: 6
    Last Post: 03-14-2011, 09:37 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