Ho una form si un file excel vba con la quale devo fare login sulla tabella Users.
le credenziali sono: UserName: ***
Password: ***
I record sulla tabella Users del db Access sono presenti.
Inspiegabilmente esce per record non presente.
Ho fatto tutti i controlli che potevo, ma non ne vengo a capo.
Il codice che uso è il seguente:
Private Sub btnConferma_Click()
Dim myConn As ADODB.Connection
Dim rs1 As ADODB.Recordset
Set myConn = GetDBConnection(ActiveWorkbook.Path & "\Covesap.accdb")
Strsql = "SELECT users.Id_Utente, users.User_Id_Utente, users.Stato_Utente, users.Password_Utente, users.CognomeNome_Utente, users.UserLevel, T_Profilo.D_UserLevel" & _
" FROM Users INNER JOIN T_Profilo ON T_Profilo.ID_UserLevel = users.UserLevel " & _
" WHERE (((users.User_Id_Utente)='" & Trim(Me.txtUserName) & "' and (users.Password_Utente)= '" & Me.txtPassword & "'))"
Set rs1 = myConn.Execute(Strsql)
If rs1.State = 1 Then
UserLogged = rs1("Id_Utente")
UserLoggedProfile = rs1("UserLevel")
Unload Me 'chiudo completamente login
frmMain.Show
Else
UserLogged = 0
MsgToEdit = "* Utente Inesistente *"
Call sendMessage(MsgToEdit, True)
Me.PallinoPassword.Visible = True
Me.PallinoUserName.Visible = True
Exit Sub
End If
rs1.Close
Set rs1 = Nothing
myConn.Close
Set myConn = Nothing
End Sub
la query va in errore come da screnshot

Nella tabella Users del db Access il record esiste

per cercare il problema ho fatto un metodo in cui eseguivo la lettura per la solo Username e la lettura va a buon fine.
Ho creato perciò un metodo in cui faccio la lettura per la solo password e non funziona
il codice usato è il seguente:
Private Sub testPassword()
Dim myConn As ADODB.Connection
Dim rs1 As ADODB.Recordset
Set myConn = GetDBConnection(ActiveWorkbook.Path & "\Covesap.accdb")
Strsql = "SELECT users.Id_Utente, users.User_Id_Utente, users.Stato_Utente, users.Password_Utente, users.CognomeNome_Utente, users.UserLevel, T_Profilo.D_UserLevel" & _
" FROM Users INNER JOIN T_Profilo ON T_Profilo.ID_UserLevel = users.UserLevel " & _
" WHERE (((users.Password_Utente)='" & Trim(Me.txtPassword) & "'))"
Set rs1 = myConn.Execute(Strsql)
If rs1.State = 1 Then
UserLogged = rs1("Id_Utente")
UserLoggedProfile = rs1("UserLevel")
Application.Wait DateAdd("s", 1, Now)
Unload Me 'chiudo completamente login
frmMain.Show
Else
UserLogged = 0
MsgToEdit = "* Utente Inesistente *"
Call sendMessage(MsgToEdit, True)
Me.PallinoPassword.Visible = True
Me.PallinoUserName.Visible = True
Exit Sub
End If
rs1.Close
Set rs1 = Nothing
myConn.Close
Set myConn = Nothing
End Sub
va in errore "3021" come evidenziato
Non capisco da dove nasca questo tipo di errore dato che il record è correttamente presente in db.
Come posso risolvere il problema ?
Grazie
Moreno