
27-07-20, 13:28
|
| Όνομα: ΕΞΑΡΧΟΣ Έκδοση λογισμικού Office: Ms-Office 2016 Γλώσσα λογισμικού Office: Ελληνική | | Εγγραφή: 15-02-2020
Μηνύματα: 104
| |
Καλημέρα σας. Σας ευχαριστώ για την μέχρι τώρα πολύτιμη βοήθεια σας.
εγώ προσάρμοσα τον κώδικα που βρήκα στην επισυναπτόμενη ΒΔ που ανεβάσατε, πιο πάνω στη δίκη μου εφαρμογή, έχω 3 προβλημάτακια.
1.σε περίπτωση λάθους pass η φόρμα frm_login κλείνει.
2. σε περιπτωση σωστου username, passwprd μου πεταει μυνημα type missmatch
3 θα ήθελα με την εισοδο ενος απλου user εκτος απο ολα αυτα που εχει το mudule να κρυβει - επενγροποιει και ΤΟ NAVIGATION PANE
Σας ευχαριστώ εκ των προτερων Με τιμη
ο Κωδικας είναι ο παρακάτω
Option Compare Database
Option Explicit
Dim intLogonAttempts As Integer
Dim UserGroup As Integer
Private Sub cbo_user_AfterUpdate()
UserGroup = Me.cbo_user.Column(2, Me.cbo_user.ItemsSelected)
Me.Txt_Password.SetFocus
End Sub
Private Sub cbo_user_GotFocus()
On Error Resume Next
Me.cbo_user.Requery
End Sub
Private Sub cmd_login_Click()
On Error Resume Next
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
If IsNull(Me.cbo_user) Or Me.cbo_user = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Administrator Message"
Me.cbo_user.SetFocus
Exit Sub
End If
If IsNull(Me.Txt_Password) Or Me.Txt_Password = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Administrator Message"
Me.Txt_Password.SetFocus
Exit Sub
End If
If Me.Txt_Password.Value = DLookup("Password", "tbl_login", "[UserID]=" & Me.cbo_user.Value) Then
If UserGroup = 1 Then 'Διαχειριστής
EnableProperties
ElseIf UserGroup = 2 Then 'Χρήστης
DisableProperties
Else 'Άλλο (νομίζω ότι εδώ παρουσιαζει το type mismatch)
End If
[/COLOR]
strSQL = "SELECT FirstName FROM tbl_login WHERE Username = """ & Me.cbo_user.Value & """ AND Password = """ & Me.Txt_Password.Value & """"
TempVars("Username").Value = Me.cbo_user.Value
TempVars("Position").Value = Me.Txt_Position.Value
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
Else
MsgBox "Password invalid." & vbCrLf & vbCrLf & "Try again", vbOKOnly, "Administrator Message!"
Me.Txt_Password = ""
Me.Txt_Password.SetFocus
End If
If rst.EOF Then
MsgBox prompt:="ËÜèïò username/password. ÎáíáðñïóðáèÞóå.", buttons:=vbCritical, Title:="Login Error"
Me.cbo_user.SetFocus
Else
MsgBox prompt:="Ãåéá óïõ, " & rst.Fields(0).Value & ". ÊáëÞ ÂÜñäéá", buttons:=vbOKOnly, Title:="Åðéôõ÷Þò Åßóïäïò óôçí ÅöáìïãÞ"
DoCmd.OpenForm "main_frm", acNormal
End If
Set db = Nothing
Set rst = Nothing
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "Are you a valid user?" & vbCrLf & "Contact Administrator.", vbCritical, "Failure"
End If
globals.Logging "login"
DoCmd.Close acForm, "frm_login", acSaveYes
End Sub
Private Sub cmd_Cancel_Click()
globals.Logging "ÅÎÏÄÏÓ"
DoCmd.Quit acQuitSaveAll
End Sub
|