B
Bryan Hughes
Hello,
I have been trying to create a login form with a ClassModule to log users
into particular areas. I have made the form and the ClassModule but when I
click the cmdbtn nothing happens.
The cmdbtn is called cmdACM
The OnClick event looks like this:
Private Sub cmdACM_Click()
Dim PWT As New CMTestClass1
PWT.cpw Me!txtEMPID, Me!txtPassword
End Sub
The ClassModule is called CMTestClass1
The procedure looks like this:
Option Compare Database
Sub cpw(empid As Long, pw As String)
Dim cmd1 As Command
Dim strSQL As String
Dim prm1 As ADODB.Parameter
Dim rst1 As ADODB.Recordset
'Assign the command reference and connection
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection
'SQL statement with parameters & assign to cmd1
strSQL = "Parameters Secret Long;" & _
"SELECT StaffID, Password FROM Staff " & _
"WHERE StaffID=Secret"
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText
Set prm1 = cmd1.CreateParameter("Secret", adInteger, adParamInput)
prm1.Value = empid
cmd1.Parameters.Append prm1
'line for catching SQL syntax errors
' Debug.Print cmd1.CommandText
cmd1.Execute
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
If rst1.Fields("Password") = pw Then
MsgBox "You are now authorized to make this change.",
vbInformation, "Update Client Information Authorized:"
Else
MsgBox "Invalid password. Try again or change password.",
vbCritical, "Incorrect Password:"
End If
End Sub
Why won't this work? What am I doing wrong?
Please Help
-Bryan
I have been trying to create a login form with a ClassModule to log users
into particular areas. I have made the form and the ClassModule but when I
click the cmdbtn nothing happens.
The cmdbtn is called cmdACM
The OnClick event looks like this:
Private Sub cmdACM_Click()
Dim PWT As New CMTestClass1
PWT.cpw Me!txtEMPID, Me!txtPassword
End Sub
The ClassModule is called CMTestClass1
The procedure looks like this:
Option Compare Database
Sub cpw(empid As Long, pw As String)
Dim cmd1 As Command
Dim strSQL As String
Dim prm1 As ADODB.Parameter
Dim rst1 As ADODB.Recordset
'Assign the command reference and connection
Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection
'SQL statement with parameters & assign to cmd1
strSQL = "Parameters Secret Long;" & _
"SELECT StaffID, Password FROM Staff " & _
"WHERE StaffID=Secret"
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText
Set prm1 = cmd1.CreateParameter("Secret", adInteger, adParamInput)
prm1.Value = empid
cmd1.Parameters.Append prm1
'line for catching SQL syntax errors
' Debug.Print cmd1.CommandText
cmd1.Execute
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
If rst1.Fields("Password") = pw Then
MsgBox "You are now authorized to make this change.",
vbInformation, "Update Client Information Authorized:"
Else
MsgBox "Invalid password. Try again or change password.",
vbCritical, "Incorrect Password:"
End If
End Sub
Why won't this work? What am I doing wrong?
Please Help
-Bryan