Results 1 to 14 of 14
  1. #1
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11

    How to return value from table to textbox in form?

    I am creating a forgot password form, where the users have to enter the correct login id, secret question and answer in order to return their password.

    tblUsers fields:
    Login ID
    Password
    Secret Question
    Secret Answer

    Forgot password form consist of textbox and a command button:

    login id [loginID_Text]


    secret question [SecretQ_Text]
    secret answer [SecretA_Text]
    password [Pass_Text]
    ok [ok_combo]

    Under the [Pass_Text], i included an expression in the control source to return the password as follows:

    [loginID_Text] & [SecretQ_Text] & [SecretA_Text]=DLookUp("[tblUsers]![Password]","tblUsers","Forms![Forgot Password]![loginID_Text]=[tblUsers]![Login ID]" And " [SecretQ_Text]=[tblUsers]![Secret Question]" And " [SecretA_Text]=[tblUsers]![Secret Answer]")

    However, this does not work. Can anyone help on this? or any other way that i can return the password by using only macro (no VBA).

    Thanks all in advance.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    The control should only have the DLookup().

    Assuming that all of your fields in tblUsers are text datatypes, the Dlookup() would look like this

    =DLookUp("[Password]","tblUsers","[Login ID]='" & [loginID_Text] & "' [Secret Question]= '" & [SecretQ_Text] & " AND [Secret Answer]='" & [SecretA_Text] & "'")

  3. #3
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    hi,

    i copied and paste your dlookup into the password [Pass_Text] but it show me #Error in the textbox of form view.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I forgot a single quote; please try this:

    =DLookUp("password","tblUsers","[Login ID]='" & [loginID_Text] & "' AND [Secret Question]='" & [SecretQ_Text] & "' AND [Secret Answer]='" & [SecretA_Text] & "'")

  5. #5
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    thanks it works now.
    But can i check with you, if i want the user to press the ok button then the [Pass_Text] will show the password instead. What am i suppose to do?

  6. #6
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    What you can do is when the form loads, hide the password control & when the user clicks the button show it (which will reveal the password).

    To do this you will have to create a macro for the on load event of the form. You will need to set the visible property of the password text box control to false. Then for the on click event of the command but change the visible property of the password text box control to true.

  7. #7
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    I have change the password text box control visible to No, did i change at the right place? and what macro should i set on the command button?

  8. #8
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You have to change the visible property of the password textbox control dynamically.

    As I said in my earlier post you will need 2 macros.

    The first to hide the control has to be in the On Load event of the form. That way when you open the form the control is not visible.

    The second macro has to be in the On Click event of the command button to reveal the control

  9. #9
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    sorry, i mean which actions of the macro should be used for the 2 macro? I am new to the macro actions...

  10. #10
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    The action is SetProperty for both macros.

  11. #11
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    Thanks so much for your help

  12. #12
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I use code rather than macros, so I don't know if a macro would be capable of handling what you describe.

    What I have seen before is to have a hidden control on the form and then when someone clicks the command button after entering their password, increment the control by 1 if the password is incorrect. After the control is incremented you will have to check to see if it is 3. If it is, you would close the database to prevent further attempts. The user would have to reopen the database and try again.

  13. #13
    cindytan is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Posts
    11
    do you know which macro action should i use?

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    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. Return field value based on the same table
    By snoopy2003 in forum Queries
    Replies: 2
    Last Post: 03-05-2011, 02:45 AM
  2. Replies: 3
    Last Post: 08-17-2010, 02:49 PM
  3. Replies: 2
    Last Post: 08-09-2010, 08:13 AM
  4. return last value in a sorted query / table
    By markjkubicki in forum Programming
    Replies: 5
    Last Post: 07-07-2010, 08:56 AM
  5. Replies: 1
    Last Post: 02-05-2009, 04:53 PM

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