Erreur code vba

Résolu
sanae -  
 sanae -
Bonjour,
j ai ecrit un code vba mais il me donne une erreur lors de l execution est ce que vous pouvvez maider a la corriger???
merci d avance
A voir également:

43 réponses

theMan
 
ça marche ?
0
samsan
 
nn
makhadmatch ba9i le meme prb ma3raftch chno ndir bach yat7al l formulaire selon user
ila can user=administrateur yat7l l menu1 sinon yat7al menu
Private Sub Commande8_Click()
Static i As Byte
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT [LOGIN],[PASSWORD],[USER] FROM USERS WHERE LOGIN = '" & Me.LOGIN & "' AND [PASSWORD]='" & Me.PASSWORD & "';")
If Not rs.EOF Then
If User = "administrateur" Then
stDoName = "menu1"
End If
DoCmd.OpenForm "menu1", acNormal, , , , acWindowNormal
If User = "limite" Then
DoCmd.OpenForm "menu", acNormal, , , , acWindowNormal
stDoName = "menu"
End If
DoCmd.Close acForm, "accés"
Else
MsgBox "(Identifiant, Mot de Passe) incorrect ", vbInformation, "Connexion"
i = i + 1
End If
If i = 3 Then
MsgBox "Vous avez dépassé le nombre de tentatives autorisés", vbCritical
DoCmd.Quit
End If

End Sub
chouf ila banlak chi erreur
0
theMan
 
Faire ceci:

Private Sub Commande8_Click()
Static i As Byte
Dim rs As Recordset
********Ajouter ceci*************************
Dim user AS String
***********************************
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT [LOGIN],[PASSWORD],[USER] FROM USERS WHERE LOGIN = '" & Me.LOGIN & "' AND [PASSWORD]='" & Me.PASSWORD & "';")
If Not rs.EOF Then
**************************************************
****Récupérer le user et l'afficher**************
user = rs("USER")
************Gouli lia wach hwa hadak le user ou pas******
MsgBox(user)
If User = "administrateur" Then
stDoName = "menu1"
DoCmd.OpenForm "menu1", acNormal, , , , acWindowNormal
End If
If User = "limite" Then
DoCmd.OpenForm "menu", acNormal, , , , acWindowNormal
stDoName = "menu"
DoCmd.OpenForm "menu", acNormal, , , , acWindowNormal
End If
DoCmd.Close acForm, "accés"
Else
MsgBox "(Identifiant, Mot de Passe) incorrect ", vbInformation, "Connexion"
i = i + 1
End If
If i = 3 Then
MsgBox "Vous avez dépassé le nombre de tentatives autorisés", vbCritical
DoCmd.Quit
End If

End Sub
0
sanae
 
merci bcp bcp j'ai reglé le prb grace a vous
hé 3andi d'autre probleme j'aurais besoin de toi inchallah
0