Can somebody help me?

A

an

Hello!

I'm trying protect only a form data entry (F_DataEntry)
with password with case sensitive.

1 - In command button on F_Password, I wrote next code:

Option Compare Database
Option Explicit

Private Const MAX_RETRIES As Integer = 3
Dim i As
Integer___________________________________________________
Private Sub CheckPassword_Click()

Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
Set cnn = CurrentProject.Connection
strSQL = "SELECT * FROM T_Password"
If i < MAX_RETRIES Then
rst.Open (strSQL), cnn, adOpenStatic
rst.Find "UserName = '" & Me.TextUserName & "'"
If Not rst.EOF Then
If Me.KeyCode = rst.Fields("Password") Then
'Login Successful, continue to main menu...
DoCmd.OpenForm "F_DataEntry"
DoCmd.Close acForm, "F_Password"
Exit Sub
Else
GoTo Login_Failure
End If
Else
GoTo Login_Failure
End If
Else
'Max retries passed. Boot from DB!
MsgBox "You have exceeded the maximum retries!",
vbCritical
DoCmd.Quit
End If
Login_Failure:
i = i + 1
MsgBox "Invalid username or password!", vbCritical
Exit Sub

2 - In Module i wrote:

Public MyPassword
Public Function KeyCode(Password As String) As Long
' This function will produce a unique key for the
' string that is passed in as the Password.
Dim i As Integer
Dim Hold As Long

For i = 1 To Len(Password)
Select Case (Asc(Left(Password, 10)) * i) Mod 4
Case Is = 0
Hold = Hold + (Asc(Mid(Password, i, 10)) * i)
Case Is = 1
Hold = Hold - (Asc(Mid(Password, i, 10)) * i)
Case Is = 2
Hold = Hold + (Asc(Mid(Password, i, 10)) * _
(i - Asc(Mid(Password, i, 1))))
Case Is = 3
Hold = Hold - (Asc(Mid(Password, i, 10)) * _
(i + Len(Password)))
End Select
Next i
KeyCode = Hold
End Function

3 - In T_Password I have tree fields with primmary key:

UserID AutoNumber
UserName Text
KeyCode Text (calculated with CTRL+G ?KeyCode("...") )

With theese procedures don't result.

Can somebody help me or with other solution?
Thanks in advance.
an
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top