首页 > 解决方案 > 当我单击登录按钮时,我试图打开另一个表单,要查看的数据在工作表上。我得到的错误是在 set shtTeam

问题描述

Private Sub cmdLogIn_Click()
 
Dim c, rng As Range
Dim strclocknumber, strpassword As String
Dim shtTeam As Collection
Dim bFound As Boolean
Dim rng As Long
 

Set shtEntry = ThisWorkbook.Sheets("Team") 'or wherever they are entering UN/PW
Set shtData = ThisWorkbook.Sheets("Team") 'or whatever sheet contains pws
Set rng = shtTeam("N:N") 'or whatever range contains Users, PWs should be the adjacent column

bFound = False

    strclocknumber = shtEntry.Range("N2") 'or wherever
    strpassword = shtEntry.Range("O2") 'or wherever
        For Each c In rng
             If StrComp(c, strclocknumber, vbTextCompare) = 0 And _
                StrComp(c.Offset(0, 1), strpassword, vbBinaryCompare) = 0 Then
                            DataEntryForm.Show
                bFound = True
                Exit For
             End If
        Next c

    If bFound = False Then MsgBox "Incorrect User Name or Password"

End Sub

 

Private Sub Label1_Click()

End Sub

Private Sub Label3_Click()

End Sub

Private Sub OptionButton2_Click()

End Sub

Private Sub QUIT_Click()
Unload Entranceform

End Sub

Private Sub TextBox2_Change()
End Sub

Private Sub TextBox4_Change()

End Sub
 
Private Sub UserForm_Click()

End Sub

标签: excelvba

解决方案


推荐阅读