Home All Groups Group Topic Archive Search About

Password for opening Report

Author
1 Dec 2006 2:10 AM
Roger Bell
I have used an OnClick Event procedure to Open a specific report which is
password protected as follows:

Private Sub MEMBERS_FORM_Click()
On Error GoTo Err_MEMBERS_FORM_Click

    Dim stDocName As String

    stDocName = "MEMBERS INFORMATION"
    DoCmd.OpenReport stDocName, acPreview
If InputBox("Please Enter Password") = "roger" Then
    DoCmd.OpenReport stDocName, acPreview, , , stLinkCriteria
Else
    MsgBox "Sorry, Incorrect Password"
End If

Exit_MEMBERS_FORM_Click:
    Exit Sub

Err_MEMBERS_FORM_Click:
    MsgBox Err.Description
    Resume Exit_MEMBERS_FORM_Click

End Sub

It works Ok, except when you click on the Command button to open the Report,
the actual Report appears behind the Password Box for any one to see.  Is
there any way to avoid this?
Thanks for any help

Author
1 Dec 2006 5:18 AM
tina
yes, take out the line of code that opens the report *before* the IF
statement runs.

hth


Show quoteHide quote
"Roger Bell" <RogerB***@discussions.microsoft.com> wrote in message
news:043DF616-0FD3-4562-B313-82BA2BF5B495@microsoft.com...
> I have used an OnClick Event procedure to Open a specific report which is
> password protected as follows:
>
> Private Sub MEMBERS_FORM_Click()
> On Error GoTo Err_MEMBERS_FORM_Click
>
>     Dim stDocName As String
>
>     stDocName = "MEMBERS INFORMATION"
>     DoCmd.OpenReport stDocName, acPreview
> If InputBox("Please Enter Password") = "roger" Then
>     DoCmd.OpenReport stDocName, acPreview, , , stLinkCriteria
> Else
>     MsgBox "Sorry, Incorrect Password"
> End If
>
> Exit_MEMBERS_FORM_Click:
>     Exit Sub
>
> Err_MEMBERS_FORM_Click:
>     MsgBox Err.Description
>     Resume Exit_MEMBERS_FORM_Click
>
> End Sub
>
> It works Ok, except when you click on the Command button to open the
Report,
> the actual Report appears behind the Password Box for any one to see.  Is
> there any way to avoid this?
> Thanks for any help