Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    turbo910 is offline Novice
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    21

    Change Password form

    Hi guys ive got a login form and im trying to put together a change password form also.
    now what i have already is a form with combo box for the username (combo0) a text box (oldPassword), and two more text boxes for (newPassword) and (verifyPassword). I think its all quite self explanitary for what each one does but just in case. What i want is for the user so select their username(combo0) and type in thier old password in (oldPassword), then type in a new password in (newPassword) and verify the new password in (verifyPassword). I also have a command button, but from here on out i don't know where to go, i have little knowledge in sql or vba but im willing to learn.



    I do need the help pretty fast.

    Thanks very much in advance guys

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Although you have provided very little imformation about your database I will try to give you a solution:

    The way I would do it.

    User_table:{User_id(PK),User_name,User_password}

    Now on a Blank Form in the Design View I will create a Listbox seting its Row Source Type as Table/Query
    Row source will be Table User_table.
    Use the Listbox wizard.(I used a listbox instead of a combobox.

    Now following your set up
    Select a user in the list box (ListBox0)
    Type the Old password in one text box (TextBox1)
    and the new password in the other(TextBox2).

    Create a CommandButton in its onClick event type the following code

    strOldPassword as string
    StrSQL as string

    strOldPassword=Dlookup("[User_Password]","User_id","[User_id]="& Me.ListBox0)

    if Me.TextBox1=strOldPassword then
    strSQl="UPDATE User_table SET User_password=" & "'" & Me.Text2 & "'" & " " & "WHERE User_id=" & "'" & Me.List0 &"';"
    else
    msgbox "The Old password is incorrect"
    end if

    if this solve your problem please mark this thread solved.

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    were you able to solve your problem.

  4. #4
    turbo910 is offline Novice
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    21
    No this did not work, still looking for a simple beginner solution
    Regards

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    attaching is a sample mdb. click AccessBoy password: maximum. Select user name type password click login. welcome message will appear click ok main_menu form will open click change password follow instuctions

  6. #6
    delacra is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Location
    Dominican Republic
    Posts
    9
    Hey Maximus, u r the maximus!!!! Thanks for sharing this is great!

  7. #7
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Quote Originally Posted by delacra View Post
    Hey Maximus, u r the maximus!!!! Thanks for sharing this is great!

    Thank you. I am glad the post helped you.

  8. #8
    delacra is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Location
    Dominican Republic
    Posts
    9
    Hi Maximus, Im just implemented the password in my database... everything look fine (and password changing is almost working),,, just one point... and this is that it's changing to the same password all my user... I thought i was doing something wrong but I notice the same issue with your example... Could you please be so kind and check it?
    Thanks in advance!

  9. #9
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Your problem is this:
    strSQL = "UPDATE tbluser_details SET User_password=" & "'" & Me.Text4 & "';"

    You need to include a WHERE clause that limits it to the current user.

  10. #10
    delacra is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Location
    Dominican Republic
    Posts
    9
    Hi Bob, I was trying to fix the problem, but this still, I just added the "Where"... but

    But now and receiving an error that said: "Data type mismarch in criteria expresion"...
    This code is for the same example that maximus posted in here... Could you please check it?

    Private Sub Command6_Click()
    On Error GoTo Err_Command6_Click
    Dim intUserID As Integer
    Dim strOldPassword As String
    Dim strSQL As String
    intUserID = Me.List0
    strOldPassword = DLookup("[User_password]", "tbluser_details", "[User_id]=" & intUserID)
    Select Case strOldPassword
    Case Is = Me.Text2
    strSQL = "UPDATE tbluser_details SET User_password=" & "'" & Me.Text4 & "'" & " " & "WHERE User_id=" & "'" & Me.List0 & "';"
    DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
    MsgBox "Password has been changed", vbInformation, "Password Changed"
    Case Is <> Me.Text2
    MsgBox "The Old Password doesnot match", vbInformation, "Type Correct Old Password"
    End Select

    Exit_Command6_Click:
    Exit Sub

    Err_Command6_Click:
    MsgBox Err.Description
    Resume Exit_Command6_Click

    End Sub

  11. #11
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Is User_id numeric or text? If numeric remove the quotes like this:

    strSQL = "UPDATE tbluser_details SET User_password=" & "'" & Me.Text4 & "' WHERE User_id=" & Me.List0

    And you don't need the semi colon at the end.

  12. #12
    delacra is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Location
    Dominican Republic
    Posts
    9
    Yes!!!!! Hey Bob....... Thanksssssssssssssssssssssssssssss!!!!!!! Thanks so much for all your helps, it's working perfectly now...

    Thanks for sharing your knowledge...

    You are a genius!

  13. #13
    MEDIC4NOW is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2011
    Location
    California, USA
    Posts
    1
    Thank you Mr. Larson for the fix and Maximus for the code. it works well.

  14. #14
    manaa is offline Novice
    Windows 7 32bit Access 2000
    Join Date
    Dec 2011
    Posts
    1

    Smile thanks

    Quote Originally Posted by boblarson View Post
    Is User_id numeric or text? If numeric remove the quotes like this:

    strSQL = "UPDATE tbluser_details SET User_password=" & "'" & Me.Text4 & "' WHERE User_id=" & Me.List0

    And you don't need the semi colon at the end.
    Thank you Mr. Bob I was searching about this problem for 2 weeks.
    Thanks a lot

  15. #15
    Manan Hotak is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2012
    Posts
    6

    Change Password Form error

    Hi Guys!

    I am having trouble with the following code. Every time I click on the command button I get the error message below. I think there is something with the sql statement. Please help.:

    Error Message:

    Runtime error 3075

    Syntax error (missing operator) in query expression 'Last Name=Manan Hotak'.

    The following is the code:

    Private Sub ChangePassword_Click()

    Dim strsql As String

    'Check to see if data is entered into the UserName combo box
    If IsNull(Me.cboCurrentEmployee) Or Me.cboCurrentEmployee = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Program"
    Me.cboCurrentEmployee.SetFocus
    Exit Sub
    End If

    'Check to see if data is entered into the old password box
    If IsNull(Me.oldpassword) Or Me.oldpassword = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Program"
    Me.oldpassword.SetFocus
    Exit Sub
    End If

    'Check value of password in Users to see if this
    'matches value chosen in combo box
    If Me.oldpassword.Value = DLookup("Password", "Users", "[Last Name]=""" & Me.cboCurrentEmployee.Value & """") Then

    strsql = "UPDATE Users SET password=" & "'" & Me.NewPassword.Value & "' WHERE Last Name=" & Me.cboCurrentEmployee.Value
    DoCmd.SetWarnings False
    DoCmd.RunSQL strsql
    DoCmd.SetWarnings True
    MsgBox "Password has been changed", vbInformation, "Password Changed"
    Else
    MsgBox "The Old Password does not match", vbInformation, "Type Correct Old Password"

    Exit_Command6_Click:
    Exit Sub

    Err_ChangePassword_Click:
    MsgBox Err.Description
    Resume Exit_ChangePassword_Click

    End If

    End Sub

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to create a Password Form
    By heman85 in forum Forms
    Replies: 1
    Last Post: 07-07-2011, 11:49 AM
  2. Password change issues
    By westeral in forum Access
    Replies: 0
    Last Post: 11-28-2009, 09:20 AM
  3. Color change in form filed
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-15-2009, 04:53 PM
  4. How to set a password to a form
    By heman85 in forum Security
    Replies: 0
    Last Post: 08-09-2008, 07:48 PM
  5. Change from old password to new password
    By richy in forum Security
    Replies: 0
    Last Post: 11-17-2005, 05:05 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