1
votes

Have an Access front end Login Form which includes an option for the user to change password. In frm_Login Sub I'm attempting to use the following to pass the entered username "Me.txtUserName" to frm_PassChange:

If Me.changepass = "Yes" Then
    DoCmd.OpenForm "frm_PassChange", , , , , Me.txtUserName
End If

In frm_PassChange Sub I want the user to enter a new password "Me.txtNewPass" which I will then store in a usertable X_tblUsers:

CurrentDb.Execute "UPDATE X_tblUsers SET X_tblUsers.Password = '" & Replace(Me.txtNewPass.Value, "'", "''") & "' " & _
                    "WHERE X_tblUsers.Username = '" & Me.OpenArgs & "'"

I'm getting a type mismatch error on the DoCmd.OpenForm call. Can anyone help?

1
1. Always use parameters when querying a database, see Best Practices - Executing Sql Statements. 2) Never store passwords as plain text, create a hash instead and persist the hash. When authenticating (logging in) hash the password input and compare it to the stored hash. - Igor
Igor - can you illustrate what you mean regarding using parameters? And yes, I will use hashing once I get the basic functionality working. - cixelsyd

1 Answers

1
votes

You need one more comma before your Me.txtUserName

Right now you're trying to pass it to the WindowMode argument

Just use Intellisense as you type and insert your commas - it'll popup the argument as you go along