Results 1 to 5 of 5
  1. #1
    vito1010 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    7

    Change VBA code from a form.

    I have some VBA code: ("password" is the password. In real life it's something else).



    Private Sub Command2_Click()
    If Me.TextBoxPassword = "password" Then
    DoCmd.RunMacro "Calculations.GoodPW"
    Else
    DoCmd.RunMacro "Calculations.BadPW"


    End If
    End Sub




    If I wanted to add a Change Password form for the end user, is there a way to do that from what I have?

    Thanks
    Vito

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You need a user table for storing their username and password.
    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
    vito1010 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2014
    Posts
    7
    I had a feeling I'd have to do something like that. There is no username, so I would only need to store the password in a table.
    So then the line would read:
    If Me.TextBoxPassword = [tblPassword.password] Then

    Is that the correct format?

    Thanks,
    Vito

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Not quite. Can't refer directly to table that way. If the table is the form's RecordSource and the table has only one record:

    If Me.TextBoxPassword = Me!Password Then
    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
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    You can have a drop down combo box of users (first column ID field) then when they select it use a dlookup() function to look up the table and get the password from the password field of that matching ID row

    then if the password doesn't match that - do something else.

    Note dlookup is a little slow sometimes.

    You can even have another 3rd column in the combo box but hidden with 0 width which is the password field and then see if the text box where they type the password in matches the column 3
    Code:
    if me.txtPassword = me.comboName.column(2) then
    msgbox "yay correct password, now do stuff"
    else
    msgbox "incorrect password, now do stuff"
    end if
    column index starts from 0 so you need go, 0 - 2

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

Similar Threads

  1. Replies: 5
    Last Post: 11-28-2013, 05:58 AM
  2. Replies: 8
    Last Post: 01-30-2012, 02:13 AM
  3. Code for change PW frm not working(ish)
    By Desstro in forum Programming
    Replies: 4
    Last Post: 12-02-2010, 02:50 PM
  4. how to change report code page
    By broken_ice in forum Reports
    Replies: 1
    Last Post: 06-27-2010, 02:23 AM
  5. Replies: 1
    Last Post: 08-10-2008, 01: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