JT2013
JT2013

Reputation: 643

Password Protect MS Access Report File

I'm looking to password protect a single report witihin my MS Access database. Is there a way to do this without using code? If you do use code, how do I have it such that when someone clicks the single report file, the user will be prompted for a password. BTW there are multiple reports in this one database...

Upvotes: 1

Views: 2609

Answers (1)

HansUp
HansUp

Reputation: 97131

One way to approach this would be to ask for the password at the report's open event. This simple example could be a starting point:

Private Sub Report_Open(Cancel As Integer)
    Const cstrPassWord As String = "open"
    Dim strPassWord As String
    strPassWord = InputBox("Password:")
    If Not strPassWord = cstrPassWord Then
        Cancel = True
    End If
End Sub

You could refine if you want to give the user more than one chance to get the password right ... or display a message when password entered incorrectly ... or whatever else you want.

Upvotes: 1

Related Questions