Hey thanks again Andy but unfortunately its not working right for me .. ok orginally my reports started with qrpt but i renamed all of them to rpt after making them..
so when i click on a report .. say rptLongChap
when im actually in the report the title bar says qrptLongChap as i made them from queries...
now when i tried the code ..most reports show up but not the ones i renamed .. i renamed one called
"rptUpper" to "Upper Mid West Chapter".
and it doesnt show in the list box, i've tried the AND LIKE with "Mid*" "Chapter*" but still nothing..
this is my code for the form and the command button to open the form
-----------------------------------------------------------
Private Sub cmdOpen1_Click()
On Error GoTo Err_cmdOpen1_Click
Dim stDocName As String
Dim stLinkCriteria As String
If IsNull(Me!lstReports) Then
MsgBox "You must choose a report", vbExclamation
Else
stDocName = Me!lstReports.Column(0)
If Me!lstReports.Column(1) = "rpt" Then
DoCmd.OpenReport "rpt" & stDocName, acPreview
ElseIf Me!lstReports.Column(1) = "rpf" Then
DoCmd.OpenForm "frm" & stDocName, acNormal
End If
' Me.Visible = False
End If
Exit_cmdOpen1_Click:
Exit Sub
Err_cmdOpen1_Click:
MsgBox Err.Description
Resume Exit_cmdOpen1_Click
End Sub
-----------------------------------------------------------
and this is the orginal code with the list box
SELECT DISTINCTROW Mid([Name],4) AS Expr1, MSysObjects.Type FROM MSysObjects WHERE (((MSysObjects.Type)=-32764) AND ((MSysObjects.Name) Like "rpt*")) OR ((MSysObjects.Type)=-32764) AND ((MSysObjects.Name)Like "rpf*")) ORDER BY MSysObjects.Name;
now this worked fine but until i changed the name of the reports ... nothing shows up now...
-----------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim objAO As AccessObject
Dim objCP As Object
Dim strValues As String
Set objCP = Application.CurrentProject
For Each objAO In objCP.AllReports
If Left(objAO.Name, 3) = "rpt" Or Left(objAO.Name, 3) = "rpf" Then
strValues = strValues & Mid(objAO.Name, 4) & ";" & Left(objAO.Name, 3) & ";"
End If
Next objAO
lstReports.RowSourceType = "Value List"
lstReports.RowSource = strValues
End Sub
***********************************************************