combo box to select a report to show

judeastone

Registered User.
Local time
Today, 05:27
Joined
Apr 2, 2003
Messages
16
Hello,

Just had a quick scan down the forum, can't seem to see anything similar...

I have a series of around 15 reports which i'd like to put into a drop down box, i've managed to create the box, but how do i link them in, and tell it to load them?

Is it a case of running through the wizard, putting my own values in, then opening it up in code form and putting some VBA in?

Thanks

Jude
 
This code in the Row Source of your combo box should do the trick:

SELECT [MSysObjects].[Name] FROM MSysObjects WHERE (Left([Name],1)<>"~") And ([MSysObjects].[Type])=-32764 ORDER BY [MSysObjects].[Name];

hth,
Jack
 
SELECT [MSysObjects].[Name] FROM MSysObjects WHERE (Left([Name],1)<>"~") And ([MSysObjects].[Type])=-32764 ORDER BY [MSysObjects].[Name];

Thanks

Which bits do i need to change? what is name? and type? they're all reports, all of different name... but under the one file. do i need to substituate MSysObjects with anything?

Sorry if i'm being dumb

Jude
 
You don't need to change anything. Just copy and paste the code in my response into the Row Source of your combo box and you should see a list of the reports in your database...

Jack
 
:( hmm, it only appears to be showing one empty space in the drop down box...

access 2000,

do i copy it just as it is, or do i need to put any carrage returns in or anything? just one long line?

thanks

jude
 
Put Jack's code in and then
In the after update event of the combo box

Dim rptname
rptname = Me![yourcomboname]
DoCmd.OpenReport rptname, acViewPreview

If you want to print directly use acviewnormal


HTH
Norman
 
You should see a list of your report names in the combo box. I assume that you have reports saved under the Reports tab of the Database Window. Just to be sure you have it right here is the code again. I just tested it again and it works as advertised.

SELECT [MSysObjects].[Name] FROM MSysObjects WHERE (Left([Name],1)<>"~") And ([MSysObjects].[Type])=-32764 ORDER BY [MSysObjects].[Name];

Jack
 

Users who are viewing this thread

Back
Top Bottom