email reports from list

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
 
B

Beetle

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
 
D

deb

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
 
B

Beetle

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
 

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

Top