Selasa, 06 Oktober 2015

[MS_AccessPros] Can't open form.

 

Dear all,

I have logon form "frmLogon", and I put the following code in to a command button. The problem is that the expected form didn't open. Please check what's wrong with my code? Thanks.

Private Sub Command4_Click()
On Error GoTo ErrHandle

If IsNull(Me.User) Then
  MsgBox "Please enter username", vbOKOnly, "Username required"
  Me.User.SetFocus
ElseIf IsNull(Me.Password) Then
  MsgBox "Please enter password", vbOKOnly, "Password required"
  Me.Password.SetFocus
  
Else
'test if username and password is correct
  If (IsNull(DLookup("[CompanyEmployeeUserName]", "tblCompanyEmployee", "[CompanyEmployeeUserName]='" & Me.User.Value & "' And [CompanyEmployeePassword]='" & Me.Password.Value & "'"))) Then
  Me.User.SetFocus
    MsgBox "Incorrect username or password", vbOKOnly, "Access Denied"
    Else
    
DoCmd.Close acForm, "frmLogon", acSaveNo    
    DoCmd.OpenForm "frmEmployeeWelcome", , , "CompanyEmployeeUserName='" & Me.User.Value & "'", acFormReadOnly
    
    End If
End If

ErrExit:
    Exit Sub
    
ErrHandle:
    Resume ErrExit

End Sub



Regards,
Kevin Zhao

__._,_.___

Posted by: "zhaoliqingoffice@163.com" <zhaoliqingoffice@163.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

.

__,_._,___

Tidak ada komentar:

Posting Komentar