User Security Form

mba_110

Registered User.
Local time
Today, 14:27
Joined
Jan 20, 2015
Messages
280
Hi,

I am trying to get details of user security on password reset form and it occur the following errors

before update cboLoginID if i click btnSubmitLoginID it give error

"Type mismatch"

after update cboLoginID if i click btnSubmitLoginID it give error

"running time error 3707 The Microsoft access engine doesnt recognized the value (i select from cbologinID) as a valid field name or expression.

after update of cboLoginID i want all fields that i have on form from tblUsersecurity should show records of that loginID.

my code is below.

Code:
Option Compare Database
Option Explicit
Private saved As Boolean

Private Sub BtnResetPassword_Click()
saved = True
   DoCmd.RunCommand (acCmdSaveRecord)
   Me.BtnResetPassword.Enabled = False
   saved = False
End Sub

Private Sub BtnSubmitLoginID_Click()

On Error GoTo errhandlers:

'Check to see if data is entered into the txtLoginID text box.

If IsNull(Me.cboLoginID) Or cboLoginID = "" Then
    MsgBox "You must enter a User Name !", vbOKOnly, "Required Data", vbInformation, "Login Verification"
    Exit Sub
End If
 
 If DCount("[LoginID]", "tblUserSecurity", "[LoginID]=" & Me.cboLoginID) > 0 Then
    MsgBox "Entered Login details are not matching with registered user, please provide correct login ID !", vbInformation, "Login Verification"
    Exit Sub
End If
exit_errhandlers:
Exit Sub
errhandlers:
    MsgBox Err.Description, vbCritical
    Err.Clear
    End Sub

Private Sub cboLoginID_AfterUpdate()
[COLOR="Red"]Me.Recordset.FindFirst "LoginID = " & Nz(cboLoginID, 0)[/COLOR]
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Response As Integer
If saved = False Then
    Response = MsgBox("Do you want to save the changes on this record?", vbYesNo, "Save Changes?")
    If Response = vbNo Then
       Me.Undo
    End If
    Me.BtnResetPassword.Enabled = False
End If
End Sub

Private Sub Form_Current()
DoCmd.RefreshRecord
End Sub

Private Sub Form_Dirty(Cancel As Integer)
Me.BtnResetPassword.Enabled = True
End Sub

Private Sub BtnCancel_Click()
Me.Undo
DoCmd.Close
End Sub

The code area i have highlited in red is causing the problem, and for your information i am using access 2010.

Your kind help will be appreciated.

thanks.
 
What type of data is the LoginID ?

If it's text you need to use ' ' around the value when you concatenate it;
Code:
 If DCount("[LoginID]", "tblUserSecurity", "[LoginID]=[COLOR="red"] '[/COLOR]" & Me.cboLoginID & [COLOR="Red"]"'"[/COLOR]) > 0 Then

You'll need to de this everywhere you refer to it.
 
It was definitely a text field in the previous version I helped you with
At that time I included this code:

Code:
  If Nz(DLookup("EmpID", "tblUserSecurity", "LoginID='" & Me.cboUsername & "'"), 0) <> 0 Then

Whilst you've changed it to DCount for some reason, the syntax needs to stay the same
 

Users who are viewing this thread

Back
Top Bottom