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?

Erik A
  • 31,639
  • 12
  • 42
  • 67
cixelsyd
  • 97
  • 2
  • 10
  • 1
    1. Always use parameters when querying a database, see [Best Practices - Executing Sql Statements](http://stackoverflow.com/documentation/.net/3589/ado-net/14261/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 Oct 04 '16 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. – cixelsyd Oct 04 '16 at 21:15
  • See [Is it possible to pass parameters programmatically in a Microsoft Access update query?](http://stackoverflow.com/q/16568461/1260204) – Igor Oct 04 '16 at 21:18

1 Answers1

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

dbmitch
  • 5,361
  • 4
  • 24
  • 38