Filling a combo box with names of reports

P

Paterson10987

Is there some way I can automatically put the names of my reports into the
row source of a combo box or list.

Thanks
 
A

Apprentice

I useing the code from Allen Browne. It works great to create a drop down
box to select reports, but I don't know the code to put into the
"Afterupdate" of the list box that would open the selected report in a
Preview Mode. Any help would be great....

Here is Allen's code used in the row source of the list box:


SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name) Not Like "~*" And (MsysObjects.Name) Not Like
"MSys*") AND ((MsysObjects.Type)=-32764))
ORDER BY MsysObjects.Name;
 
R

RoyVidar

Apprentice said:
I useing the code from Allen Browne. It works great to create a drop
down box to select reports, but I don't know the code to put into
the "Afterupdate" of the list box that would open the selected
report in a Preview Mode. Any help would be great....

Here is Allen's code used in the row source of the list box:


SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name) Not Like "~*" And (MsysObjects.Name) Not
Like "MSys*") AND ((MsysObjects.Type)=-32764))
ORDER BY MsysObjects.Name;

If Me!TheComboName.ListIndex <> -1 Then
DoCmd.OpenReport Me!TheComboName.Value, acViewPreview
Else
MsgBox "You must select a report first!"
End If
 
A

Apprentice

Thanks Roy.... I need a little more help here.

The sql statement I have posted in the combo box's row source is not a
function, but just a source. So where or how would I incorporate your code
in the statement? Here is both the row source and your code:

SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name) Not Like "~*" And (MsysObjects.Name) Not Like
"MSys*") AND ((MsysObjects.Type)=-32764))
ORDER BY MsysObjects.Name;

If Me!TheComboName.ListIndex <> -1 Then
DoCmd.OpenReport Me!TheComboName.Value, acViewPreview
Else
MsgBox "You must select a report first!"
End If
 
A

Apprentice

Roy, I got it. I just had to get my head around it. Your code worked great
when I created a Sub for it and then called that sub in the afterupdate of
the text box. Thanks.
 

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