Option Compare Database
Option Explicit
Private Sub AddNew_Click()
Dim txtPWD As String
Dim PWD As String
Dim Key As String
Dim strSQL As String
'On Error GoTo Error_Handler
Key = GetKey
txtPWD = fRunRC4(Me.[txtEmail], Key) ' this encrypts the users email address & gets filed 'Key' from a saved database property
PWDdate = Date
strSQL = "INSERT INTO MsysUsers (FirstName, LastName,PWD, PWDDate)"
Debug.Print strSQL
strSQL = strSQL & """SELECT '" & Me.[txtFirstName] & "' AS firstName,'"
Debug.Print strSQL
strSQL = strSQL & Me.[txtLastName] & "' AS LastName,'"
Debug.Print strSQL
strSQL = strSQL & txtPWD & "' AS PWD,'"
Debug.Print strSQL
strSQL = strSQL & "#" & Format(PWDdate, "dd/mm/yyyy") & "#" & "' AS PWDDate;"
Debug.Print strSQL
strSQL = """" & strSQL
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError
Me.lblInfo.Caption = "New user " & " " & Me.[txtFirstName] & " " & Me.[txtLastName] & " " & "has been successfully added"
exit_proc::
Exit Sub
Error_Handler:
[ATTACH type="full"]104084[/ATTACH] Call DisplayErrorMessage(Err.Number, "Add New User")
Resume exit_proc
End Sub