1

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?

3
  • 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. Commented Oct 4, 2016 at 17:56
  • Igor - can you illustrate what you mean regarding using parameters? And yes, I will use hashing once I get the basic functionality working. Commented Oct 4, 2016 at 21:15
  • See Is it possible to pass parameters programmatically in a Microsoft Access update query? Commented Oct 4, 2016 at 21:18

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.