Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > VBA Access
VBA Access Le forum pour les questions relatives au code VBA sous Access, et à son environnement de développement VBE.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/11/2011, 11h18   #1
Candidat au titre de Membre du Club
 
Homme
Étudiant
Inscription : novembre 2011
Messages : 32
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : novembre 2011
Messages : 32
Points : 12
Points : 12
Par défaut Mot de passe page d'acceuil

Bonjour , je suis actuellement en stage et je dois rédiger plusieurs formulaires sur acess pour l'aboutissement d'un projet.

j'ai rédiger une page d’accueil ( en formulaire ) , mais celle ci est différente en fonction de qui s'y identifie ( admin ou utilisateur ) , c'est là ou je bloque, j'ai crée deux bouton : un admin et un utilisateur avec comme option :
lorsqu'on clique cela ouvre le bon formulaire.

Mais voila ce dont j'ai besoin c'est de mettre un mot de passe au bouton admin pour sécuriser l'accès a son formulaire et je ne sait pas comment m'y prendre.

Ou une faire apparaitre une zone de texte au moment du clique par exemple, là sa deviendrait plus simple.
juice est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/11/2011, 11h30   #2
Membre éclairé
 
Avatar de @rkane
 
Homme Patrick
developpeur amateur dans mon cadre professionnel
Inscription : juin 2006
Messages : 499
Détails du profil
Informations personnelles :
Nom : Homme Patrick
Âge : 52
Localisation : France, Val de Marne (Île de France)

Informations professionnelles :
Activité : developpeur amateur dans mon cadre professionnel
Secteur : Administration - Collectivité locale

Informations forums :
Inscription : juin 2006
Messages : 499
Points : 360
Points : 360
tiens voilà le code que j'utilise, tu remplaces "responsable" par "admin" tu ajoutes une colonne "Admin" dans ta table des utilisateurs ou du personnel (c'est selon ) de type oui/non. à +
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
Option Compare Database
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Const giMaxLogin As Byte = 3 'nombre maxi autorisé de tentative de connexion
 
Private Sub BoutonUtilisateur_Click()
Me.Password = LCase$(Nz(Password))
 
On Error GoTo errortag
   Dim oDb As DAO.Database
   Dim rst As DAO.Recordset
   Dim sSql As String
   Dim bBadLogin As Boolean, bClose As Boolean
   Static i As Byte
 
   i = i + 1 'incrémente les tentatives
 
   If IsNull(Me.Login) Or IsNull(Me.Password) Then
      bBadLogin = True
   Else
      Set oDb = CurrentDb
      ' Cherche l'utilisateur dans la table, en sachant que login ne peut contenir le caractère <'> ni <">
 sSql = "SELECT * FROM Personnel WHERE  Utilisateur = true AND Nom = '" & Me.Login & "'"
      Set rst = oDb.OpenRecordset(sSql, dbOpenSnapshot)
      If Not rst.EOF Then
      ' Vérifier que le mot de passe est égal au mot de passe saisie crypté
      If rst("password") = Me.Password Then 'Mot de passe ok
            i = 0
            bBadLogin = False
         Else 'Mot de passe incorrect
            bBadLogin = True
            Me.Password.SetFocus
            Me.Password.ForeColor = vbRed
         End If
      Else ' pas de login trouvé
         bBadLogin = True
      End If
   End If
   If bBadLogin = True Then 'si tentative mauvaise
      If i < giMaxLogin Then 'si nb tentative < au maxi
 
MsgBox "NOM D'UTILISATEUR OU MOT DE PASSE ERRONE" & vbCrLf & "IL VOUS RESTE " & (giMaxLogin - i) & " TENTATIVE(S) DE CONNECTION"
      Else 'si nb tentative >= maxi => on ferme
         MsgBox "VOUS AVEZ DEPASSE LE NOMBRE DE TENTATIVES AUTORISEES !"
      DoCmd.Quit
         'bClose = True
      End If
   End If
Fin:
   Set rst = Nothing
   Set oDb = Nothing
   If bBadLogin = False Then
      DoCmd.OpenForm "Identite", , , , , , "Connexion"
      DoCmd.SelectObject acForm, Me.Name, False
      DoCmd.OpenForm "MenuPrincipal"
      DoCmd.Close acForm, Me.Name
   ElseIf bClose = True Then
      DoCmd.Close acForm, Me.Name
   End If
   Exit Sub
errortag:
End Sub
 
Private Sub BoutonResponsable_Click()
Me.Password = LCase$(Nz(Password))
 
On Error GoTo errortag
   Dim oDb As DAO.Database
   Dim rst As DAO.Recordset
   Dim sSql As String
   Dim bBadLogin As Boolean, bClose As Boolean
   Static i As Byte
 
   i = i + 1 'incrémente les tentatives
 
   If IsNull(Me.Login) Or IsNull(Me.Password) Then
      bBadLogin = True
   Else
      Set oDb = CurrentDb
      ' Cherche l'utilisateur dans la table, en sachant que login ne peut contenir le caractère <'> ni <">
  sSql = "SELECT * FROM Personnel WHERE Responsable = true AND Nom = '" & Me.Login & "'"
      Set rst = oDb.OpenRecordset(sSql, dbOpenSnapshot)
      If Not rst.EOF Then
      ' Vérifier que le mot de passe est égal au mot de passe saisie crypté
      If rst("password") = Me.Password Then 'Mot de passe ok
            i = 0
            bBadLogin = False
         Else 'Mot de passe incorrect
            bBadLogin = True
            Me.Password.SetFocus
            Me.Password.ForeColor = vbRed
 
         End If
      Else ' pas de login trouvé
         bBadLogin = True
      End If
   End If
   If bBadLogin = True Then 'si tentative mauvaise
 
      If i < giMaxLogin Then 'si nb tentative < au maxi
 
         MsgBox "NOM D'UTILISATEUR OU MOT DE PASSE ERRONE" & vbCrLf & "IL VOUS RESTE " & (giMaxLogin - i) & " TENTATIVE(S) DE CONNECTION"
      Else 'si nb tentative >= maxi => on ferme
         MsgBox "VOUS AVEZ DEPASSE LE NOMBRE DE TENTATIVES AUTORISEES !"
      DoCmd.Quit
         'bClose = True
      End If
   End If
Fin:
   Set rst = Nothing
   Set oDb = Nothing
   If bBadLogin = False Then
      DoCmd.OpenForm "Identite", , , , , , "Connexion"
      DoCmd.SelectObject acForm, Me.Name, False
      DoCmd.OpenForm "Responsables"
      DoCmd.Close acForm, Me.Name
   ElseIf bClose = True Then
      DoCmd.Close acForm, Me.Name
   End If
   Exit Sub
errortag:
End Sub
__________________

@rkane est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/11/2011, 11h59   #3
Candidat au titre de Membre du Club
 
Homme
Étudiant
Inscription : novembre 2011
Messages : 32
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : novembre 2011
Messages : 32
Points : 12
Points : 12
Nickel , je te remercie sa va m'aider , même si je vais supprimer les tentatives de connexion ^^
juice est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 17h11.


 
 
 
 
Partenaires

Hébergement Web