PC Review


Reply
Thread Tools Rate Thread

Protection Problems was Report Protection

 
 
=?Utf-8?B?Q01vcmdhbg==?=
Guest
Posts: n/a
 
      21st Sep 2004
I have attepmted to use this code within my db... and I am running into the
same troubles that anonymous ran into on 6/29/04, Report Protection.
Can anyone tell me what he/she did to overcome these problems?
Please
Thank You
Christy

Original Message:
6/29/04 - Report Protection - Access General Questions
From anonymous

It's close to working, but it doesn't seem to go to the
password table to check the password when I enter it.
Here's the code:

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, 1)) * I) Mod 4
Case Is = 0
Hold = Hold + (Asc(Mid(Password, I, 1)) * I)
Case Is = 1
Hold = Hold - (Asc(Mid(Password, I, 1)) * I)
Case Is = 2
Hold = Hold + (Asc(Mid(Password, I, 1)) * _
(I - Asc(Mid(Password, I, 1))))
Case Is = 3
Hold = Hold - (Asc(Mid(Password, I, 1)) * _
(I + Len(Password)))
End Select
Next I
KeyCode = Hold
End Function


Private Sub Report_Open(Cancel As Integer)
Dim Hold As Variant
Dim tmpKey As Long
Dim I As Integer
Dim rs As Recordset
Dim db As Database

On Error GoTo Error_Handler
' Check to see if the user is passing in the
Password.
Hold = InputBox("Please Enter Your
Password", "Enter Password")
' Open the table that contains the password.
Set db = CurrentDb
Set rs = db.OpenRecordset("tblPassword",
dbOpenTable)
rs.Index = "PrimaryKey"
rs.Seek "=", Me.Name
If rs.NoMatch Then
MsgBox "Sorry cannot find password info.
Please Try Again"
Cancel = -1
Else
' Test to see if the key generated matches the
key in
' the table; if there is not a match, stop the
form
' from opening.
If Not (rs![KeyCode] = KeyCode(CStr(Hold)))
Then
MsgBox "Sorry you entered the wrong
password. " & _
"Please try again.",
vbOKOnly, "Incorrect Password"
Cancel = -1
End If
End If
rs.Close
db.Close
Exit Sub

Error_Handler:
MsgBox Err.Description, vbOKOnly, "Error #" &
Err.Number
Exit Sub
End Sub

My table is tblPassword; My Form is frmPassword; My Module is Module1

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Turn protection Off... <run code>... turn protection back on DFS Microsoft Excel Programming 3 4th Oct 2009 04:52 AM
WS Protection: Different Levels of Protection on Different Ranges =?Utf-8?B?Q2FybWk=?= Microsoft Excel Misc 4 31st Aug 2007 02:26 PM
says General protection fault!.AND protection error 704 =?Utf-8?B?YnJvbmNtYW40MmE=?= Windows XP Performance 1 18th Nov 2006 05:05 PM
Cell Protection vs. Worksheet Protection =?Utf-8?B?a213aGl0dA==?= Microsoft Excel Misc 4 24th Sep 2006 02:37 AM
Worksheet protection is gone and only wokbook protection can be se =?Utf-8?B?RXJpYyBDLg==?= Microsoft Excel Misc 4 2nd May 2006 04:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:50 AM.