By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,940 Members | 611 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,940 IT Pros & Developers. It's quick & easy.

Password Protected ListBox Selection/Command Button

P: 4
tbl_Report
- DBReportName
- MenuReportName
- FacilityID
- ReportType
- Viewable (Yes/No)
- PasswordProtected (Yes/No)
- Password (Encrypted)

On MenuReport form...
1. User Selects Facility ID in a combobox
2. User Selects MenuReportName in list box (row source dependant on Facility ID selection)
3. User enters date range in txtDateFrom and txtDateTo
4. User clicks "View Report" button

Problem: I want the user to enter a password to view the report.

Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim strReport As String
Dim strPW As String
Dim strGetPWReq As String

strReport = Me.listReport.Column(0)

If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo & vbNullString) = 0 Then
MsgBox "Please Select A Date Range!", _
vbInformation, "Required Data..."
Exit Sub
Else
If Me.listReport.Column(5) = -1 Then
strGetPWReq = InputBox("Enter Password")
strPW = Me.listReport.Column(6)
If strPW = strGetPWReq Then
DoCmd.OpenReport strReport, acViewReport
Else
MsgBox "Incorrect Password"
Exit Sub

End If
End If
End If

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub


Dead Button...nothing happens when I click it. Any noticeable flaws in the code?
Jan 9 '08 #1
Share this Question
Share on Google+
1 Reply


P: 4
I have made a few changes, but still no luck...

Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim strReport As String
Dim strPW As String
Dim strGetPWReq As String

strReport = Me.listReport.Column(0)
strPW = Me.listReport.Column(6)


If Len(Me.txtdatefrom & vbNullString) = 0 Or Len(Me.txtDateTo & vbNullString) = 0 Then
MsgBox "Please Select A Date Range!", _
vbInformation, "Required Data..."
Exit Sub
Else

If Me.listReports.Column(5) = -1 Then

strGetPWReq = InputBox("Enter Password")
If strGetPWReq = strPW Then
DoCmd.OpenReport strReport, acViewReport
DoCmd.Maximize
Else
MsgBox "Incorrect Password"
Exit Sub
End If
Else
DoCmd.OpenReport strReport, acViewReport
DoCmd.Maximize
End If
End If

Exit_cmdReport_Click:
Exit Sub

Err_cmdReport_Click:
MsgBox Err.Description
Resume Exit_cmdReport_Click
End Sub
Jan 9 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.