A
Anthony Viscomi
I have the following code behind the form's "On Open" event:
Sub Form_Open(Cancel As Integer)
On Error GoTo ErrHandler
Dim App As Object
Dim CurProject As Object
Dim CollReports As Object
Dim objRpt As Object
Dim strRptName As String, strReportList As String, i As Integer
If SysCmd(acSysCmdAccessVer) < 9 Then
i = 0
Set CurProject = CurrentDb
Set CollReports = CurProject.Containers("Reports")
For i = 0 To CollReports.Documents.Count - 1
strRptName = CollReports.Documents(i).Name
If InStr(strRptName, "_cmgt") > 0 Then
strReportList = strReportList & strRptName & ";"
End If
Next i
Else
Set App = Application
Set CurProject = App.CurrentProject
Set CollReports = CurProject.AllReports
For Each objRpt In CollReports
strRptName = objRpt.Name
If InStr(strRptName, "_cmgt") > 0 Then
strReportList = strReportList & strRptName & ";"
End If
Next
End If
strReportList = Left(strReportList, Len(strReportList) - 1)
Me!RptLstBox.RowSource = strReportList
ExitProc:
Exit Sub
ErrHandler:
MsgBox Err & " " & Error, , "Form Open"
Resume ExitProc
End Sub
My question is; how can I open the report by clicking on it? I know that I
need to place my code behind the lstbox "double click" event; but that's
where I'm lost.
Sub Form_Open(Cancel As Integer)
On Error GoTo ErrHandler
Dim App As Object
Dim CurProject As Object
Dim CollReports As Object
Dim objRpt As Object
Dim strRptName As String, strReportList As String, i As Integer
If SysCmd(acSysCmdAccessVer) < 9 Then
i = 0
Set CurProject = CurrentDb
Set CollReports = CurProject.Containers("Reports")
For i = 0 To CollReports.Documents.Count - 1
strRptName = CollReports.Documents(i).Name
If InStr(strRptName, "_cmgt") > 0 Then
strReportList = strReportList & strRptName & ";"
End If
Next i
Else
Set App = Application
Set CurProject = App.CurrentProject
Set CollReports = CurProject.AllReports
For Each objRpt In CollReports
strRptName = objRpt.Name
If InStr(strRptName, "_cmgt") > 0 Then
strReportList = strReportList & strRptName & ";"
End If
Next
End If
strReportList = Left(strReportList, Len(strReportList) - 1)
Me!RptLstBox.RowSource = strReportList
ExitProc:
Exit Sub
ErrHandler:
MsgBox Err & " " & Error, , "Form Open"
Resume ExitProc
End Sub
My question is; how can I open the report by clicking on it? I know that I
need to place my code behind the lstbox "double click" event; but that's
where I'm lost.