2
'Procedimento para o Comando Entrar
Sub Entrar()
'converte texto usuario para minusculo - formando um padrao
frmLogin.txtUsuario = LCase(frmLogin.txtUsuario)
' Primeira parte - Verifica os campos vazios
If frmLogin.txtUsuario = "" Then
MsgBox "Entre com o nome do Usuário", vbInformation, "USUÁRIO"
Exit Sub
End If
If frmLogin.txtSenha = "" Then
MsgBox "Entre com a senha do Usuário", vcInformation, "SENHA"
Exit Sub
End If
' Segunda parte - verifica se é administrador e se for entra na planilha
If frmLogin.txtUsuario = "admin" And frmLogin.txtSenha = "admin" Then
MsgBox "Bem Vindo Administrador.", vbOKOnly, "ACESSO LIBERADO"
gravarRelatório
LimparfrmLogin
Unload frmLogin
Application.Visible = True
Sheets("USUÁRIO").Visible = xlSheetVisible
Sheets("REL_ACESSO").Visible = xlSheetVisible
Sheets("CONDIÇÃO.H.EXTRA").Visible = xlSheetVisible
Sheets("UTIL.CONTROL.PONTO").Visible = xlSheetVisible
Sheets("EMPREGADO.TESTE1").Select
Exit Sub
End If
' Terceira parte - verifica se o usuário e senha estão no banco de dados
linha = 2
Usuario = frmLogin.txtUsuario
Senha = frmLogin.txtSenha
Do Until Sheets("USUÁRIO").Cells(linha, 1) = ""
If Sheets("USUÁRIO").Cells(linha, 1) = Usuario And Sheets("USUÁRIO").Cells(linha, 2) = Senha Then
MsgBox "Bem Vindo " & Usuario, vbOKOnly, "ACESSO LIBERADO"
gravarRelatório
LimparfrmLogin
Unload frmLogin
Application.Visible = True
Sheets("USUÁRIO").Visible = xlSheetVeryHidden
Sheets("REL_ACESSO").Visible = xlSheetVeryHidden
Sheets("CONDIÇÃO.H.EXTRA").Visible = xlSheetVeryHidden
Sheets("UTIL.CONTROL.PONTO").Visible = xlSheetVeryHidden
Sheets("EMPREGADO.TESTE1").Select
Exit Sub
End If
linha = linha + 1
Loop
MsgBox "Usuário ou Senha Inválidos", vbCritical, "ACESSO NEGADO"
LimparfrmLogin
frmLogin.txtUsuario.SetFocus
Exit Sub
End Sub
No need to enter another code yet. Who can help and need more information.
Thanks in advance!
What’s the question? Where does the problem occur? In addition to posting the code, it is important you explain how the problem occurs.
– user28595
Ricardo, welcome to Soft. Go to Ajuda and take the Tour, to make better use of the resources here, and see how to deal with the questions and answers. Try to be clear in your questions.
– Leo
Hi. Welcome to Sopt. What colleagues mean is that it’s not enough just to put the code, because that way someone interested in helping you needs to copy it to put it on a spreadsheet and try to test it. Or else carefully analyze line by line to try to find where the error is. How you already know where the mistake is, please click [Edit] and add this information (the line where it occurs) to the question. And, do not forget: do the [tour] and read mainly [Ask].
– Luiz Vieira
Hi Ricardo, what? Did the answer serve you or was it useful? Here in the community we mark (check below the arrows next to the answer) the answer when this occurs, and we can vote by triggering the answers and questions arrows as well. I await your feedback, because if you have not solved the problem, give us more information to help you. Do the tour if you have not done it yet, it is important!
– Leo