Quote:
Originally Posted by alphaomega3
I have created a form for listing my reports using tips and code from Allen Browne's website. The Code is as Follows:
- Function EnumReports(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
-
' Purpose: Supplies the name of all saved reports to a list box.
-
' Usage: Set the list box's RowSourceType property to:? EnumReports
-
' leaving its RowSource property blank.
-
' Notes: All arguments are provided to the function automatically.
-
' Author: Allen Browne allen@allenbrowne.com Feb.'97.
-
-
Dim db As Database, dox As Documents, i As Integer
-
Static sRptName(255) As String ' Array to store report names.
-
Static iRptCount As Integer ' Number of saved reports.
-
-
' Respond to the supplied value of "code".
-
Select Case code
-
Case acLBInitialize ' Called once when form opens.
-
Set db = CurrentDb()
-
Set dox = db.Containers!Reports.Documents
-
iRptCount = dox.Count ' Remember number of reports.
-
For i = 0 To iRptCount - 1
-
sRptName(i) = dox(i).Name ' Load report names into array.
-
Next
-
EnumReports = True
-
Case acLBOpen
-
EnumReports = Timer ' Return a unique identifier.
-
Case acLBGetRowCount ' Number of rows
-
EnumReports = iRptCount
-
Case acLBGetColumnCount ' 1 column
-
EnumReports = 1
-
Case acLBGetColumnWidth ' 2 inches
-
EnumReports = 2 * 1440
-
Case acLBGetValue ' The report name from the array.
-
EnumReports = sRptName(row)
-
Case acLBEnd
-
Erase sRptName ' Deallocate array.
-
iRptCount = 0
-
End Select
-
End Function
How do I keep this from listing "~TMP*" repoorts?
'I've returned a sub-set of your code with changes indicated by a *. It was
'tested on my PC and works fine. Hope this helps you...
- * Dim T As Integer 'New Array Index to prevent "Holes"
-
-
' Respond to the supplied value of "code".
-
Select Case code
-
Case acLBInitialize ' Called once when form opens.
-
Set db = CurrentDb()
-
Set dox = db.Containers!Reports.Documents
-
iRptCount = dox.Count ' Remember number of reports.
-
For i = 0 To iRptCount - 1
-
* If Left(dox(i).Name, 1) <> "~" Then
-
* sRptName(T) = dox(i).Name ' Load report names into array.
-
* T = T + 1
-
* End If
-
Next
-
EnumReports = True