Ola a todos, estou tendo um problema com a parte de permissões, toda vez que tento logar dependendo do login tenho um problema na parte de login.tenho um erro na linha referente ao tipo de login, alguém aqui pode me ajudar .att
- Código: Selecionar todos
Dim sPermissao
Private Sub btnAjuda_Click()
MsgBox "O Sistema vai Expirar em:" & Chr(10) & Resultado & Chr(32) & " Dias", vbInformation, "Sistema Gestor - V 1.0"
End Sub
Private Sub cmdCancelar_Click()
Unload frmLogin
ThisWorkbook.Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub
Private Sub cmdOk_Click()
Dim sSenhaUsuario As String
Dim sSenhaADM As String
sLinha = 3
Dim var1, var2 As Date
var1 = Date
var2 = Time
If ckbGestor = False Then
If TxtUsuario = "" Then
MsgBox "Digite o nome de usuário. Verifique!", vbExclamation, "Sistema Gestor - V 1.0"
TxtUsuario.SetFocus
Exit Sub
Else
If TxtSenha = "" Then
MsgBox "Digite a senha o Usuário. Verifique!", vbExclamation, "Sistema Gestor - V 1.0"
TxtSenha.SetFocus
Exit Sub
End If
End If
'Usuario Comum
While (Plan3.Cells(sLinha, 1) <> TxtUsuario)
sLinha = sLinha + 1
If sLinha > 10 Then
MsgBox "Usuário não cadastrado! Por favor Verifique.", vbExclamation, "Sistema Gestor - V 1.0"
TxtUsuario.Text = ""
TxtUsuario.SetFocus
Exit Sub
End If
Wend
'Verifica a Senha USUARIO COMUM
sSenhaUsuario = Plan3.Cells(sLinha, 2).Value
'Verifica PERMISSÃO e carrega a Variavel
sPermissao = Plan3.Cells(sLinha, 3).Value
If TxtSenha <> sSenhaUsuario Then
MsgBox "A Senha esta Incorreta! Por favor Verifique!", vbExclamation, "Sistema Gestor - V 1.0"
TxtSenha.Text = ""
TxtSenha.SetFocus
Exit Sub
Else
'OPÇÕES USUÁRIO COMUM
MsgBox "Bem Vindo : " & TxtUsuario, vbInformation, "Sistema Gestor - V 1.0"
While (Plan4.Cells(sLinha, 1) <> "")
sLinha = sLinha + 1
Wend
Plan4.Cells(sLinha, 1) = TxtUsuario.Value
Plan4.Cells(sLinha, 2) = var1
Plan4.Cells(sLinha, 3) = var2
Plan4.Cells(sLinha, 4) = "Usuário"
'PlanApresentacao.Visible = xlSheetVisible
'Sheets("Apresentação").Activate
ActiveWindow.DisplayWorkbookTabs = False
Hide
Call protege
'Rotina - Opções das Permissões
Call Permissoes
frmMenu.Show
End If
Else
If TxtUsuario = "" Then
MsgBox "Digite um nome de usuário Valido", vbExclamation, "Sistema Gestor - V 1.0"
Exit Sub
TxtUsuario.SetFocus
Else
If TxtSenha = "" Then
MsgBox "Digite uma Senha Valida", vbExclamation, "Sistema Gestor - V 1.0"
Exit Sub
TxtSenha.SetFocus
End If
'Usuario ADMINISTRADOR
While (Plan3.Cells(sLinha, 5) <> TxtUsuario)
sLinha = sLinha + 1
If sLinha > 10 Then
MsgBox "Gestor não cadastrado! Por favor Verifique", vbExclamation, "Sistema Gestor - V 1.0"
Call LimparCampos
Exit Sub
End If
Wend
'Verifica Senha ADM
sSenhaADM = Plan3.Cells(sLinha, 6).Value
If TxtSenha <> sSenhaADM Then
MsgBox "A Senha esta Incorreta! Por favor Verifique", vbExclamation, "Sistema Gestor - V 1.0"
Call LimparCampos
Exit Sub
Else
'OPÇÕES DO ADMINISTRADOR
MsgBox "Bem Vindo Gestor : " & TxtUsuario, vbInformation, "Sistema Gestor - V 1.0"
' PERMISSÃO ADMINISTRADOR JA NA ROTINA
'sPermissao = "ADM"
'Unload Me
While (Plan4.Cells(sLinha, 1) <> "")
sLinha = sLinha + 1
Wend
Plan4.Cells(sLinha, 1) = TxtUsuario.Value
Plan4.Cells(sLinha, 2) = var1
Plan4.Cells(sLinha, 3) = var2
Plan4.Cells(sLinha, 4) = "Gestor"
ActiveWindow.DisplayWorkbookTabs = True
'PlanApresentacao.Visible = xlSheetVisible
'Sheets("Apresentação").Select
Hide
sPermissao = "ADM"
Call Permissoes
frmMenu.Show
End If
End If
End If
End Sub
Sub LimparCampos()
TxtUsuario.Text = ""
TxtSenha.Text = ""
TxtUsuario.SetFocus
End Sub
Private Sub cmdLimpar_Click()
Call LimparCampos
End Sub
Private Sub TxtUsuario_Change()
TxtUsuario.Value = UCase(TxtUsuario.Value)
End Sub
Private Sub TxtSenha_Change()
TxtSenha.Value = UCase(TxtSenha.Value)
End Sub
Private Sub UserForm_Terminate()
Application.DisplayAlerts = False
ActiveWorkbook.Save
Application.Quit
End Sub
Private Sub UserForm_Initialize()
TxtUsuario.SetFocus
With frmLogin
.Caption = "Área Restrita ao Acesso - Sistema Gestor - V 1.0"
End With
HideCloseButton Me
End Sub
Sub Permissoes()
Select Case sPermissao
Case 1
'OPÇÕES FORMULÁRIO MENU
With frmMenu
.btnProtocolo.Enabled = True
.btnPesquisarProtocolo.Enabled = True
.btnUsuario.Enabled = True
.btnRequisicao.Enabled = False
.btnPesquisarRequisicao.Enabled = False
.btnBackup.Enabled = True
.btnPlanilha.Enabled = False
End With
'OPÇÕES FORMULÁRIO CADASTRO DE USUARIO
With frmUsuario
.btAlterar.Enabled = True
.btInserir.Enabled = True
.btLimpar.Enabled = True
.btSair.Enabled = True
.OptGestor.Value = False
.OptGestor.Enabled = False
End With
Case 2
'OPÇÕES FORMULÁRIO MENU USUARIO
With frmMenu
.btnProtocolo.Enabled = True
.btnPesquisarProtocolo.Enabled = False
.btnUsuario.Enabled = False
.btnRequisicao.Enabled = False
.btnPesquisarRequisicao.Enabled = False
.btnBackup.Enabled = True
.btnPlanilha.Enabled = False
End With
'OPÇÕES FORMULÁRIO REGISTRO DE DOCUMENTOS
With frmCadastro
.optExcluir.Value = False
.optExcluir.Enabled = False
.btnImprimir.Enabled = True
.btnImprimirc.Enabled = False
.btnCadastro.Enabled = True
.optNovo.Value = False
.optNovo.Enabled = True
End With
'OPÇÕES FORMULÁRIO REGISTRO DE DOCUMENTOS
With frmCliente
.OptPessoaFisica.Value = True
.OptPessoaFisica.Enabled = True
.btnAlterar.Enabled = False
.OptPessoaJuridica.Value = True
.OptPessoaJuridica.Enabled = True
End With
Case 3
'OPÇÕES FORMULÁRIO MENU USUARIO COMUM
With frmMenu
.btnProtocolo.Enabled = True
.btnPesquisarProtocolo.Enabled = True
.btnUsuario.Enabled = False
.btnRequisicao.Enabled = False
.btnPesquisarRequisicao.Enabled = False
.btnBackup.Enabled = True
.btnPlanilha.Enabled = False
End With
'OPÇÕES FORMULÁRIO MENU USUARIO COMUM
With frmCadastro
.optExcluir.Value = False
.optExcluir.Enabled = False
.btnImprimir.Enabled = True
.btnImprimirc.Enabled = False
.btnCadastro.Enabled = True
.optNovo.Value = False
.optNovo.Enabled = True
End With
'OPÇÕES FORMULÁRIO MENU USUARIO COMUM
With frmCliente
.OptPessoaFisica.Value = True
.OptPessoaFisica.Enabled = True
.btnAlterar.Enabled = False
.OptPessoaJuridica.Value = True
.OptPessoaJuridica.Enabled = True
End With
Case 4
With frmMenu
.btnProtocolo.Enabled = True
.btnPesquisarProtocolo.Enabled = True
.btnRequisicao.Enabled = True
.btnPesquisarRequisicao.Enabled = True
.btnBackup.Enabled = True
.btnPlanilha.Enabled = False
End With
Case "ADM" 'SOMENTE ADMINISTRADOR
'OPÇÕES FORMULÁRIO CADASTRO
With frmMenu
.btnProtocolo.Enabled = True
.btnUsuario.Enabled = True
.btnRequisicao.Enabled = True
.btnBackup.Enabled = True
.btnPlanilha.Enabled = True
End With
End Select
End Sub