more password user for more form in microsoft articles

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HI
I have question form Microsoft knowledge base articles :

http://support.microsoft.com/?id=209871
http://support.microsoft.com/?id=179371

They work very good
But i would like to add more password for more user to open the same 2
forms. I
try to remove the primary key in order to add more user for the the two same
forms that i want to protect.
It only work with the first password and the first form was enter in the
password table. How to work around this. Thanks
simon
 
HI
I have question form Microsoft knowledge base articles :

http://support.microsoft.com/?id=209871
http://support.microsoft.com/?id=179371

They work very good
But I would like to add more password for more user to open the same 2
forms. I
try to remove the primary key in order to add more user for the two same
forms that I want to protect.
It only work with the first password and the first form was enter in the
password table. How to work around this. Thanks

Hi Simon,

Sure, we can do this pretty easily. Just remember that this technique for
password protecting forms and reports can be easily circumvented by
people with sufficient Access knowledge. For the *best* security you
should use User Level Security. Just thought I should point that out.

Ok, moving on. Follow the steps below to achieve your goal:
(These steps assume you are following article 209871 to the letter)

1. Make a backup of your database first

2. Repeat step 1 (don't make me come over there Simon <g>)

3. Open the tblPassword in Design View

4. Remove the PrimaryKey for ObjectName

5. Create a compound PrimaryKey using ObjectName and KeyCode
Double check the Indexes - they should look exactly like this:

Index Name Field Name Sort Order
PrimaryKey ObjectName Ascending
KeyCode Ascending

(at the bottom of the Index box you should see)
Primary Yes
Unique Yes
Ignore Nulls No

6. Close and save the changes to the table

7. Add additional records for one of your forms or reports. Access
should allow you enter multiple records for each object, provided of
course, you have different KeyCodes.

8. Make sure you have a referenc set to the DAO object library in using
Access 2000 or 2002. You probably already have it anyway.

9. Open one of your test forms or reports and REPLACE the Form_Open
code with the following (watch out for any line wrapping):

'*************Code Start**************
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

' This code is from Microsoft Knowledge Base Article 209871
' http://support.microsoft.com/?id=209871
'
' Code Adapted by Jeff Conrad - Access Junkie
' Copyright © 2005 Conrad Systems Development
'
' Adapted code allows for more than one password for objects
' Need to make a compound PrimaryKey using ObjectName
' and KeyCode
'
' You are free to use this code in any projects providing
' you agree to the following two conditions:
' 1. This copyright information remains intact
' 2. You admit you are an Access Junkie
' (Why else would you be looking at this?) :-)

Dim varHold As Variant
Dim lngTmpKey As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim strObjectName As String

' Capture the name of this object
strObjectName = Me.Name

' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
' Assign the password they entered to our variant
varHold = MyPassword

' Run the module code to covert the password to a number
lngTmpKey = KeyCode(CStr(varHold))

' Open the table that contains the password information
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblPassword", dbOpenTable)

' Look for a PrimaryKey match using object name and password they used
rst.Index = "PrimaryKey"
rst.Seek "=", strObjectName, lngTmpKey
If rst.NoMatch Then
' No password match found in the table for this object
MsgBox "The password you have entered is incorrect." _
& vbNewLine & "Please try again or contact an " _
& "Administrator.", vbExclamation + vbOKOnly, _
"Incorrect Password"
' Stop the form from opening
Cancel = True
End If

ExitPoint:
' Cleanup Code
On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & err.Number _
& vbNewLine & "Error Description: " & err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'*************Code Start**************

10. Compile the code, save, and close the form/report.

11. Now test opening the form/report with the different passwords
you entered into the table. The form/report will now allow more than
one password to be entered (provided it matches of course).

12. Repeat copying/pasting the Open code above to all the forms and reports
that you want to password protect.

That's it!
 
Jeff Conrad said:
Hi Simon,

Sure, we can do this pretty easily. Just remember that this technique for
password protecting forms and reports can be easily circumvented by
people with sufficient Access knowledge. For the *best* security you
should use User Level Security. Just thought I should point that out.

Ok, moving on. Follow the steps below to achieve your goal:
(These steps assume you are following article 209871 to the letter)

1. Make a backup of your database first

2. Repeat step 1 (don't make me come over there Simon <g>)

3. Open the tblPassword in Design View

4. Remove the PrimaryKey for ObjectName

5. Create a compound PrimaryKey using ObjectName and KeyCode
Double check the Indexes - they should look exactly like this:

Index Name Field Name Sort Order
PrimaryKey ObjectName Ascending
KeyCode Ascending

(at the bottom of the Index box you should see)
Primary Yes
Unique Yes
Ignore Nulls No

6. Close and save the changes to the table

7. Add additional records for one of your forms or reports. Access
should allow you enter multiple records for each object, provided of
course, you have different KeyCodes.

8. Make sure you have a referenc set to the DAO object library in using
Access 2000 or 2002. You probably already have it anyway.

9. Open one of your test forms or reports and REPLACE the Form_Open
code with the following (watch out for any line wrapping):

'*************Code Start**************
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

' This code is from Microsoft Knowledge Base Article 209871
' http://support.microsoft.com/?id=209871
'
' Code Adapted by Jeff Conrad - Access Junkie
' Copyright © 2005 Conrad Systems Development
'
' Adapted code allows for more than one password for objects
' Need to make a compound PrimaryKey using ObjectName
' and KeyCode
'
' You are free to use this code in any projects providing
' you agree to the following two conditions:
' 1. This copyright information remains intact
' 2. You admit you are an Access Junkie
' (Why else would you be looking at this?) :-)

Dim varHold As Variant
Dim lngTmpKey As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim strObjectName As String

' Capture the name of this object
strObjectName = Me.Name

' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
' Assign the password they entered to our variant
varHold = MyPassword

' Run the module code to covert the password to a number
lngTmpKey = KeyCode(CStr(varHold))

' Open the table that contains the password information
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblPassword", dbOpenTable)

' Look for a PrimaryKey match using object name and password they used
rst.Index = "PrimaryKey"
rst.Seek "=", strObjectName, lngTmpKey
If rst.NoMatch Then
' No password match found in the table for this object
MsgBox "The password you have entered is incorrect." _
& vbNewLine & "Please try again or contact an " _
& "Administrator.", vbExclamation + vbOKOnly, _
"Incorrect Password"
' Stop the form from opening
Cancel = True
End If

ExitPoint:
' Cleanup Code
On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & err.Number _
& vbNewLine & "Error Description: " & err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'*************Code Start**************

10. Compile the code, save, and close the form/report.

11. Now test opening the form/report with the different passwords
you entered into the table. The form/report will now allow more than
one password to be entered (provided it matches of course).

12. Repeat copying/pasting the Open code above to all the forms and reports
that you want to password protect.

That's it!
Hi,
How about access 97 with artical 179371. I'm using office pro 97.
Thks
Simon
 
Hi,
How about access 97 with article 179371. I'm using office pro 97.
Thanks
Simon

Believe it or not Simon, the code I put together and tested WAS using
Access 97! The only big difference between the KB articles for 97 and
2000 was the use of a password form. The 97 code uses an InputBox
to grab the password, but it can easily be seen while you type it in. The
2000 article just adds an extra step of creating a small password form
to grab the password.

This is all you need to do to make this work in 97:
1. Use the same module code you already have
2. Follow the instructions in article 209871 about creating
a small password form called frmPassword.
3. Follow the instructions as I posted before about modifying
the table and form/report Open code.

That's it!
It will work on 97, 2000, 2002, and 2003.
Trust me.
:-)

--
Jeff Conrad
Access Junkie
Bend, Oregon
 
try it on access 97,
UNEXPECTED ERROR
THE FOLLOWING ERROR HAS OCCURRED
ERROR NUMBER :13
ERROR DESCRIPTION: TYPE MISSMATCH
 
try it on access 97,
UNEXPECTED ERROR
THE FOLLOWING ERROR HAS OCCURRED
ERROR NUMBER :13
ERROR DESCRIPTION: TYPE MISSMATCH

Hi Simon,

You probably missed a step or two as it works just fine for me in Access 97.
Let's start over, but this time let's just create a new blank database to play
with OK?

1. Carefully follow the steps 1-9 using this link:

http://support.microsoft.com/?id=209871

2. Now open the tblPassword again in Design View as we need to make a change.

3. Remove the PrimaryKey for ObjectName

4. Create a compound PrimaryKey using ObjectName and KeyCode
Double check the Indexes (View | Indexes) - they should look exactly like this:

Index Name Field Name Sort Order
PrimaryKey ObjectName Ascending
KeyCode Ascending

(at the bottom of the Index box you should see)
Primary Yes
Unique Yes
Ignore Nulls No

You MUST make sure this is done correctly!

5. Close and save the changes to the table.

6. Now do steps 10-13 just as you see them here:

http://support.microsoft.com/?id=209871

7. Create a new blank form for testing and copy/paste this code into
the Open event (watch out for any line wrapping):

'*************Code Start**************
Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

' This code is from Microsoft Knowledge Base Article 209871
' http://support.microsoft.com/?id=209871
'
' Code Adapted by Jeff Conrad - Access Junkie
' Copyright © 2005 Conrad Systems Development
'
' Adapted code allows for more than one password for objects
' Need to make a compound PrimaryKey using ObjectName
' and KeyCode
'
' You are free to use this code in any projects providing
' you agree to the following two conditions:
' 1. This copyright information remains intact
' 2. You admit you are an Access Junkie
' (Why else would you be looking at this?) :-)

Dim varHold As Variant
Dim lngTmpKey As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim strObjectName As String

' Capture the name of this object
strObjectName = Me.Name

' Prompt the user for the Password.
DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog
' Assign the password they entered to our variant
varHold = MyPassword

' Run the module code to covert the password to a number
lngTmpKey = KeyCode(CStr(varHold))

' Open the table that contains the password information
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("tblPassword", dbOpenTable)

' Look for a PrimaryKey match using object name and password they used
rst.Index = "PrimaryKey"
rst.Seek "=", strObjectName, lngTmpKey
If rst.NoMatch Then
' No password match found in the table for this object
MsgBox "The password you have entered is incorrect." _
& vbNewLine & "Please try again or contact an " _
& "Administrator.", vbExclamation + vbOKOnly, _
"Incorrect Password"
' Stop the form from opening
Cancel = True
End If

ExitPoint:
' Cleanup Code
On Error Resume Next
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & err.Number _
& vbNewLine & "Error Description: " & err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
'*************Code Start**************

8. Compile the code, save, and close the form

9. Now go back to the table and enter a password for this form.
Make sure you use the KeyCode technique.

10. Create another record in the table, but this time choose a different
password.

11. Now open up your test form. The password form you created
should open up first. Enter one of the passwords you made in the
table. The form should open OK.

12. Now close the form and re-open. This time try the other password.
Again, the form should open OK.

13. One last time close the form and then re-open. Now use a password
that you did not assign to this form. A message box will appear and
the main form will not open.

Everything should work just fine.

For additonal form and reports you just need to copy/paste the same Open
event code above and make the correct table records.
 
Back
Top