I can't log in with my own database in excel

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
I'm creating a database in excel, as such I have the users' data and their passwords inserted in the tables (picture), I would like to know if the way I'm checking the credentials is correct because I'm not able to log in with the data I enter even though they correspond to the ones in the table. Can someone help me?

I enter the Username as "calmeiro_andre" and the password "1234" as in the table but I can't login

VBA Code:
  Private Sub bt_seguinte_Click()

Dim usuario_verify, senha_verify, c As Long

usuario_verify = tb_usuario.Value
senha_verify = tb_senha.Value
lb_erro_usuario.Visible = False
lb_erro_senha.Visible = False

Select Case True

Case Trim(usuario_verify) = "" And Trim(senha_verify) = ""
    lb_erro_usuario.Visible = True
    lb_erro_senha.Visible = True

Case Trim(usuario_verify) = ""
    lb_erro_usuario.Visible = True

Case Trim(senha_verify) = ""
      lb_erro_senha.Visible = True

Case Else

Application.ScreenUpdating = False

contar_usuarios = Cells(Rows.Count, "D").End(xlUp).Row

For c = 2 To contar_usuarios

    Sheets("Usuários").Cells(c, 4).Select

    If ActiveCell = usuario_verify Then
        If ActiveCell.Offset(0, 1) <> senha_verify Then
            lb_erro_senha.Visible = True
            lb_erro_senha.Caption = "*Senha ou Nome de Usuário incorretos"
            MsgBox "1"

        Else
            Registar.Show

        End If


    ElseIf c = contar_usuarios And ActiveCell <> usuario_verify Then
        lb_erro_senha.Visible = True
        lb_erro_senha.Caption = "*Senha ou Nome de Usuário incorretos"


    ElseIf ActiveCell <> usuario_verify Then
    End If

Next c
End Select

Application.ScreenUpdating = True

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Are the passwords in your table text or numbers?
 
Upvote 0
Are the passwords in your table text or numbers?
I forgot to put the image

Capturar.JPG
 
Upvote 0
If users are creating their own passwords, you would be better off making sure that they are all text.
 
Upvote 0
Solution
Se os usuários estiverem criando suas próprias senhas, seria melhor certificar-se de que todas sejam de texto.
I changed the variable to string and formal tables to text and it worked, thank you friend!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,761
Messages
6,132,569
Members
449,736
Latest member
anthx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top