Link criteria problem

atisz

Registered User.
Local time
Today, 16:03
Joined
Apr 5, 2005
Messages
96
Hello,

I have cboUtilizator (User) for choosing username, txtp for password input and a text box called lngEmpID wich Control Source =[cboUtilizator]. The user select his username, enter his password then when he click the OK command button the code verify if the password is correct for selected user, and if it's correct based on lngEmpID, opens a ChangePassword form showing the user data. This way he can change only his password, 'cause this is the only information he can access.
The problem is: If I put this code

Code:
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "ChangePass"
        stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria

to a command button, it's OK. But if I insert it in the code, the way showed bellow, it isn't working anymore, on the line
Code:
 stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
it give me the following error message:
"Run-time error '2467'
The expression you entered referes to an object that is closed or doesn't exist."

Can anybody help me to fix this?

Thanx,
Attila


Code:
Private Sub Command5_Click()
    
'Check to see if data is entered into the UserName (cboUtilizator) combo box

    If IsNull(Me.cboUtilizator) Or Me.cboUtilizator = "" Then
            MsgBox "Va rugam introduceti numele de utilizator.", vbOKOnly, "Completare obligatorie"
            Me.cboUtilizator.SetFocus
        Exit Sub
    End If

'Check to see if data is entered into the password box (txtp)

    If IsNull(Me.txtp) Or Me.txtp = "" Then
            MsgBox "Va rugam introduceti parola.", vbOKOnly, "Completare obligatorie"
            Me.txtp.SetFocus
        Exit Sub
    End If

'Check value of password in table users (Utilizatori) to see if this matches value chosen in combo box

    If Me.txtp.Value = DLookup("Parola", "Utilizatori", "[lngEmpID]=" & Me.cboUtilizator.Value) Then
    If DLookup("TipUtilizator", "Utilizatori", "[lngEmpID]=" & Me.cboUtilizator.Value) = "Admin" Then
        lngMyEmpID = Me.cboUtilizator.Value
      
        DoCmd.Close acForm, "LogareConsolaUser", acSaveNo
        DoCmd.Close acForm, "Meniu", acSaveNo
        
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "ChangePass"
        stLinkCriteria = "[lngEmpID]=" & Me![lngEmpID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
        Else
 
           Dim stDocName4 As String
           Dim stLinkCriteria1 As String
           stDocName4 = "ErrLog"
           DoCmd.OpenForm stDocName4, , , stLinkCriteria1
           Me.txtp.SetFocus
    End If
    End If
    
End Sub
 
Is the control lngEMpID on euither of these forms: LogareConsolaUser, Meniu?

If so, you need to get the value assigned before closing the form.
 
SJ McAbney said:
Is the control lngEMpID on euither of these forms: LogareConsolaUser, Meniu?

If so, you need to get the value assigned before closing the form.

Thanks, SJ!

Ohhhhhhhhhh, this is the problem?! And I was wondering why its working with that button, but not with the one with the full code. I had waste a lot of time around it :(
Yes, the lngEMpID is on the form LogareConsolaUser. But how do i get the value before closing the form? Or I could just simply leave the LogareConsolaUser form open (not so nice, but this way it's working).
?

Attila
 

Users who are viewing this thread

Back
Top Bottom