WTF Happened?

K

Keypad

Hello all,

I have the following code that allows me to send multiple reports to
multiple email recipients which works fine in Office 2003 but not Office
2007. In 2007 my reports don't show up in my control window, everything else
seems fine. I don't have Office 2007 so I can't troubleshoot the problem.
Can someone with 2007 load this code and see if works for them.

Here's the code:

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

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 
D

Douglas J. Steele

Just set the RowSource of your list box to

SELECT [Name] FROM MSysObjects WHERE [Type]=-32764 ORDER BY [Name]
 
K

Keypad

Douglas,

OK, I understand about the MSysObjects part, but the "SELECT [name]" part is
confusing. Do you mean "name" literally or do I plug in the name of my
report?
Also, if I plug in the name of a report there then how do I address the
other reports since I have a total of three.

KP


Douglas J. Steele said:
Just set the RowSource of your list box to

SELECT [Name] FROM MSysObjects WHERE [Type]=-32764 ORDER BY [Name]

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Hello all,

I have the following code that allows me to send multiple reports to
multiple email recipients which works fine in Office 2003 but not Office
2007. In 2007 my reports don't show up in my control window, everything
else
seems fine. I don't have Office 2007 so I can't troubleshoot the problem.
Can someone with 2007 load this code and see if works for them.

Here's the code:

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

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 
K

Keypad

ruralguy,

Yea, the Row Source Type was already set to value list so that was a good
catch. Thanks for noticing.

KP
 
D

Douglas J. Steele

Plug that exact expression, as is, into the RowSource.

No offense, but wouldn't it have been faster for you to try it rather than
wait for an answer?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Douglas,

OK, I understand about the MSysObjects part, but the "SELECT [name]" part
is
confusing. Do you mean "name" literally or do I plug in the name of my
report?
Also, if I plug in the name of a report there then how do I address the
other reports since I have a total of three.

KP


Douglas J. Steele said:
Just set the RowSource of your list box to

SELECT [Name] FROM MSysObjects WHERE [Type]=-32764 ORDER BY [Name]

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Hello all,

I have the following code that allows me to send multiple reports to
multiple email recipients which works fine in Office 2003 but not
Office
2007. In 2007 my reports don't show up in my control window,
everything
else
seems fine. I don't have Office 2007 so I can't troubleshoot the
problem.
Can someone with 2007 load this code and see if works for them.

Here's the code:

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

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 
K

Keypad

Douglas,

Trying it first would have been faster, but when it didn't work on A2007
last night I was tweaking the code and ended up locking my friends laptop and
killing the apps he had running, OOPS! My friend was not pleased :-( and it
was a real "want to get away" moment for me. A little gun shy today as I
have a huge file downloading right now with less than desirable bandwidth to
boot.

I'll plug in the code how you wrote it and try it later tonight. Thanks for
helping out with this one Douglas.

KP

Douglas J. Steele said:
Plug that exact expression, as is, into the RowSource.

No offense, but wouldn't it have been faster for you to try it rather than
wait for an answer?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Douglas,

OK, I understand about the MSysObjects part, but the "SELECT [name]" part
is
confusing. Do you mean "name" literally or do I plug in the name of my
report?
Also, if I plug in the name of a report there then how do I address the
other reports since I have a total of three.

KP


Douglas J. Steele said:
Just set the RowSource of your list box to

SELECT [Name] FROM MSysObjects WHERE [Type]=-32764 ORDER BY [Name]

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hello all,

I have the following code that allows me to send multiple reports to
multiple email recipients which works fine in Office 2003 but not
Office
2007. In 2007 my reports don't show up in my control window,
everything
else
seems fine. I don't have Office 2007 so I can't troubleshoot the
problem.
Can someone with 2007 load this code and see if works for them.

Here's the code:

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

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 
D

Douglas J. Steele

Don't forget to ensure that the RowSourceType is set to Table/Query

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Douglas,

Trying it first would have been faster, but when it didn't work on A2007
last night I was tweaking the code and ended up locking my friends laptop
and
killing the apps he had running, OOPS! My friend was not pleased :-( and
it
was a real "want to get away" moment for me. A little gun shy today as I
have a huge file downloading right now with less than desirable bandwidth
to
boot.

I'll plug in the code how you wrote it and try it later tonight. Thanks
for
helping out with this one Douglas.

KP

Douglas J. Steele said:
Plug that exact expression, as is, into the RowSource.

No offense, but wouldn't it have been faster for you to try it rather
than
wait for an answer?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keypad said:
Douglas,

OK, I understand about the MSysObjects part, but the "SELECT [name]"
part
is
confusing. Do you mean "name" literally or do I plug in the name of my
report?
Also, if I plug in the name of a report there then how do I address the
other reports since I have a total of three.

KP


:

Just set the RowSource of your list box to

SELECT [Name] FROM MSysObjects WHERE [Type]=-32764 ORDER BY [Name]

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hello all,

I have the following code that allows me to send multiple reports to
multiple email recipients which works fine in Office 2003 but not
Office
2007. In 2007 my reports don't show up in my control window,
everything
else
seems fine. I don't have Office 2007 so I can't troubleshoot the
problem.
Can someone with 2007 load this code and see if works for them.

Here's the code:

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

Exit_OF:
Exit Sub
Err_OF:
MsgBox Err & " " & Error, , "Report Open"
Resume Exit_OF

End Sub
 

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