Frothingslosh
Premier Pale Stale Ale
- Local time
- Today, 11:13
- Joined
- Oct 17, 2012
- Messages
- 3,276
I'm creating a form that will list all report objects in my database, and then the user will select one and print it.
The controls on the form are:
I'm really rusty (it's been years since I've done this), so I'm not sure how I could go in and make sure that reports beginning with "rpt*" don't get listed. If anyone can tell me what I need to do to do that, I'd be most appreciative. Same with ensuring only one report gets selected.
List box code:
The controls on the form are:
- List box named lstReports
- Check box named chkPreview
- Command button named cmdOpenReport
I'm really rusty (it's been years since I've done this), so I'm not sure how I could go in and make sure that reports beginning with "rpt*" don't get listed. If anyone can tell me what I need to do to do that, I'd be most appreciative. Same with ensuring only one report gets selected.
List box code:
Code:
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 (removed email due to post count) Feb.'97.
Dim db As dao.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