Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Protecting Specific Records

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I created a database and now want to be able to password protect specific records. Is there a way that I can create a command button somewhere in the form of a record so the user can password protect it and if someone tries to open that record they have to know the password? I want to also be able to take the password protect off. For example lets say a user wants to password protect a record until it has been reviewed etc...how can I accomplish something like this? Thanks
 
Either you create a new table 1:1 that contains the record ID and its password
or your table structure needs a supplementary field "Password".
In either case you need to check via VBA before exposing any record whether it is protected or not. If so, you need a PW-checking routine.
ATTENTION: You have to make certain that the password can not be seen by unauthorized users.
 
Just took a 'simple' approach with some string manipulations. Won't claim it is absolutely secure but as long as the user cant access the VB code (and thus the 'algorithm' it can be quite a puzzle to get the password. Anyway, for me it is working

Public Function ScramblePassword(strPassword As String)
For IntCounter = 0 To Len(strPassword) - 1
Step1 = Step1 & Chr((Asc(Mid(strPassword, _
Len(strPassword) - IntCounter, 1)) + _
Len(strPassword)) + 15)
Step2 = Step2 & Chr((Asc(Mid(strPassword, _
Len(strPassword) - IntCounter, 1)) + _
(Len(strPassword) - 5) + 10))
Next
For IntCounter = Len(strPassword) To 1 Step -1
Step3 = Step3 & Mid(Step2, IntCounter, 1)
Next
For IntCounter = 1 To Len(strPassword)
Step4 = Step4 & Mid(Step1, IntCounter, 1) & _
Mid(Step3, IntCounter, 1)
Next

ScramblePassword = Left(Step4, Len(strPassword)) & _
Chr(Len(strPassword) + 50) & Right(Step4, Len(Step4) _
- Len(strPassword))
End Function




' Pasword checking Routine :
' The rsPerson!Password is a recordset coming from a table
' in the database where the encrypted passwords are stored.
' The Password is coming from user input in a form

If rsPerson!Password <> ScramblePassword(Password) Then
....
End If







' Use this if nessescary to make the password readable
' again. You do not nessescarily need this in your
' database/code though.

Public Function UnScramblePassword(strPassword As String) Step4 = Left(strPassword, Int(Len(strPassword) / 2)) _
& Right(strPassword, Int(Len(strPassword) / 2))
For IntCounter = 1 To Len(Step4) Step 2
Step1 = Step1 & Mid(Step4, IntCounter, 1)
Next IntCounter
For IntCounter = 0 To Len(Step1) - 1
UnScramblePassword = UnScramblePassword & Chr(Asc(Mid _
(Step1, Len(Step1) - IntCounter, 1)) - Len(Step1) - 15)
Next IntCounter
End Function
&quot;In three words I can sum up everything I've learned about life: it goes on.&quot;
- Robert Frost 1874-1963
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top