I have a list box that displays the names of reports that can be printed. The list box is populated from a table with three columns - an autonumber, the name of the report, and a description. I hide the first two, displaying the third. I want the user to be able to double-click the report they want and have it come up, but I'm having trouble with the code. This is what it looks like:
The error message I get is that the report name is misspelled or doesn't exist. I've triple-checked the spelling of all of the reports and they are all correct, but no matter which report I try to open I get the error message.
Any ideas?
Private Sub lstReport_DblClick(Cancel As Integer)
On Error GoTo Err_lstReport_DblClick
Dim stRptName As String
stRptName = "'" & Me.lstReport.Column(1) & "'"
If Me.lstReport.Column(1) = "" Then
Exit SubEnd If
DoCmd.OpenReport stRptName, acViewPreview
Exit_lstReport_DblClick:
Exit Sub
Err_lstReport_DblClick:
MsgBox Err.Description
Resume Exit_lstReport_DblClick
End Sub
The error message I get is that the report name is misspelled or doesn't exist. I've triple-checked the spelling of all of the reports and they are all correct, but no matter which report I try to open I get the error message.
Any ideas?