Password Check

B

Bryan Hughes

Hello,

Client DB each client is assigned a Case Manager. Only the case manager
assigned to
the record can update it, so I a need pw check before a CM can update
record.


I have a Client Form that is read only. There are several cmdbtns that when
user clicks a popup login form is opened.

The user enters their Employee ID and Password this uses a class module that
checks empid and pw. If they are the assigned case manager for the record
and their pw is correct then they are authorized to make changes to this
record.

Now, what I need to do is if they are authorized then I need to put focus
back on Client Form, and Enable or Unlock the text boxes they need to change
the data in.

How can I do this?

The cmdbtn on the Client Form looks like this:
************************************
Private Sub cmdCCN_Click()
DoCmd.OpenForm "frmCase_Manager_Login", acNormal

End Sub
*************************************

The cmdbtn for login form looks like this:
***********************************
Private Sub cmdACM_Click()
Dim PWT As New CMTestClass1
PWT.cmcpw Me.txtEMPID, Me.txtPassword

End Sub
**********************************

The ClassModule looks like this:
************************************
' Use to Change Client Name
Sub cmcpw(EMPID As String, PW As String)
Dim rst1 As ADODB.Recordset
Dim cmd1 As Command
Dim strSQL As String
Dim vEMPID As String
Dim vCMTest As String
vEMPID = Forms!frmClient_Details_RO!txtEMPID


Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection

'SQL statement and assign to cmd1
strSQL = "SELECT EMPID, Password FROM Staff WHERE EMPID='" & EMPID & "'" &
";"
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText

If EMPID <> vEMPID Then
MsgBox "You are not the Assigned Case Manager for this Client. You are
not authorized to make this change.", vbCritical, "Not Assigned Case
Manager:"
DoCmd.Close acForm, "frmCase_Manager_Login"
Exit Sub
Else
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
If rst1.Fields("Password") = PW Then
MsgBox "You are now authorized to make this change.",
vbInformation
Else
MsgBox "Incorrect password. Try again or change password",
vbCritical
End If
End If

End Sub
************************************************************************

Please Help
-Bryan
 
B

Bryan Hughes

Hello,

Please ignore first post, it should read like this.

I have a Client Form that is read only. There are several cmdbtns that when
user clicks a popup login form is opened.

The user enters their Employee ID and Password this uses a class module that
checks empid and pw. If they are the assigned case manager for the record
and their pw is correct then they are authorized to make changes to this
record.

Now, what I need to do is if they are authorized then I need to put focus
back on Client Form, and Enable or Unlock the text boxes they need to change
the data in.

How can I do this?

The cmdbtn on the Client Form looks like this:
************************************
Private Sub cmdCCN_Click()
DoCmd.OpenForm "frmCase_Manager_Login", acNormal

End Sub
*************************************

The cmdbtn for login form looks like this:
***********************************
Private Sub cmdACM_Click()
Dim PWT As New CMTestClass1
PWT.cmcpw Me.txtEMPID, Me.txtPassword

End Sub
**********************************

The ClassModule looks like this:
************************************
' Use to Change Client Name
Sub cmcpw(EMPID As String, PW As String)
Dim rst1 As ADODB.Recordset
Dim cmd1 As Command
Dim strSQL As String
Dim vEMPID As String
Dim vCMTest As String
vEMPID = Forms!frmClient_Details_RO!txtEMPID


Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = CurrentProject.Connection

'SQL statement and assign to cmd1
strSQL = "SELECT EMPID, Password FROM Staff WHERE EMPID='" & EMPID & "'" &
";"
cmd1.CommandText = strSQL
cmd1.CommandType = adCmdText

If EMPID <> vEMPID Then
MsgBox "You are not the Assigned Case Manager for this Client. You are
not authorized to make this change.", vbCritical, "Not Assigned Case
Manager:"
DoCmd.Close acForm, "frmCase_Manager_Login"
Exit Sub
Else
Set rst1 = New ADODB.Recordset
rst1.Open cmd1
If rst1.Fields("Password") = PW Then
MsgBox "You are now authorized to make this change.",
vbInformation
Else
MsgBox "Incorrect password. Try again or change password",
vbCritical
End If
End If

End Sub
************************************************************************

Please Help
-Bryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top