email reports from list

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

deb

I am using Arvin Meyer's email code. Excellent work, Arvin!!!

the below code displays a list box of all reports...

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!lstRpt.RowSource = strRptList

I Only want certail reports to be listed.
Is it possible to limit to reports that start with rpt
or better yet, is it possible to only display reports in a table. (make a
table with thr report names of the ones I want to display in the email list?

Thanks
 
You could do either, but the table would (IMO) be the cleaner,
more easily manageable solution. If you do want to do it in code
you could try modifying your existing code like this (assuming
you want only report names that begin with rpt);

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

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

Me!lstRpt.RowSource = strRptList
 
How would I make it read a table?
--
deb


Beetle said:
You could do either, but the table would (IMO) be the cleaner,
more easily manageable solution. If you do want to do it in code
you could try modifying your existing code like this (assuming
you want only report names that begin with rpt);

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

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

Me!lstRpt.RowSource = strRptList
 
In that case you wouldn't really need any code, you would just
base the rowsource of your list box on the table that holds
the report names, i.e.;

Select ReportName From tblReports
 
Back
Top