List of Reports and Forms

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

I am using the below to create a listbox containing Reports. How can I
show Reports and Forms in the same listbox?

Set db = CurrentDb()
Set contr = db.Containers("Reports")


Thanks
 
deb said:
I am using the below to create a listbox containing Reports. How can I
show Reports and Forms in the same listbox?

Set db = CurrentDb()
Set contr = db.Containers("Reports")

Your code is probably the same as:

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_OF
Dim db As Database
Dim i As Integer
Dim contr As Container
Dim strRptList As String
Dim strRptName As String
Dim Length As Integer

Set db = CurrentDb()
Set contr = db.Containers("Reports")

strRptList = ""
For i = 0 To contr.Documents.Count - 1
strRptName = contr.Documents(i).name
If strRptList <> "" Then strRptList = strRptList & ";"
Length = Len(strRptName)
strRptList = strRptList & strRptName
Next i

Me!List2.RowSource = strRptList

Exit_OF:
Exit Sub
Err_OF:
msgbox err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub

It should now look like:

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_OF
Dim db As Database
Dim i As Integer
Dim contr As Container
Dim strRptList As String
Dim strRptName As String
Dim Length As Integer
Dim strFrmList As String
Dim strFrmName As String

Set db = CurrentDb()
Set contr = db.Containers("Reports")

strFrmList = ""
For i = 0 To contr.Documents.Count - 1
strFrmName = contr.Documents(i).name
If strFrmList <> "" Then strFrmList = strFrmList & ";"
Length = Len(strFrmName)
strFrmList = strFrmList & strFrmName
Next i

strRptList = ""
For i = 0 To contr.Documents.Count - 1
strRptName = contr.Documents(i).name
If strRptList <> "" Then strRptList = strRptList & ";"
Length = Len(strRptName)
strRptList = strRptList & strRptName
Next i

Me!List2.RowSource = strFrmList & strRptList

Exit_OF:
Exit Sub
Err_OF:
msgbox err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 
I have an email button on a report form that launches the email form. Behind
the email button I have the following code to populate the lstRpt list box
that containes the list of reports and forms. I am using a table to store
the names of the reports and forms that I want to display in the lstbox

Forms!frmEmailReport!lstRpt.RowSource="SELECT tEmailReport.eMailReportID, " _
& "tEmailReport.RptNameDesign, tEmailReport.RptName, tEmailReport.OnFormName
FROM tEmailReport " _
& "WHERE (((tEmailReport.OnFormName)=""Deliverables"")) ORDER BY
tEmailReport.RptName;"

On the form_Open of the email report form I have the below code.
Set db = CurrentDb()
Set contr = db.Containers("Reports")

This works well if I am email reports but when I try to send a form(chart) I
get "The report you entered in either the property sheet or macro is
misspelled or refers to a report that doesn't exist."

any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

email reports from list 3
Selecting and Sending Reports Via E-Mail 9
Module Not Found 5
WTF Happened? 6
Open Report with Criteria From Form 6
Delete DB objects 3
Print values of a listbox 2
Report names in control 3

Back
Top