Puzzled About Listboxes :)

donbettis

Old User Gone Astray
Local time
Today, 13:16
Joined
Jan 23, 2001
Messages
103
Ok I give… After reading numerous postings on “listbox” I still have no ideal how to do what I would like to do or, even if it’s possible. I would assume with the capability of Access almost anything can be, if you know how… I may have over looked a post that answers my question. If this is so, I do apologize for posting an already answered question.

What I would like to do is this:

I would like to have a form containing a listbox that has all my reports listed in it… I would then like to be able to click or double-click one of the reports and have it print out the report for only the current record on another form… I think I have kinda figured out how to get my report listed in a listbox however, I have no idea how to make them clickable.

Any and all help would be helpful...

Thanks

Don
 
Use the reports query on this page:
http://www.mvps.org/access/queries/qry0002.htm

to get your list of reports for your listbox (use the reports query as your listbox recordsource)

Next, create a function to run a report using criteria from a form like so:

function MyFunction(strReportName as string, frm as form) as integer
on error resume next
dim strWhereCond as string
strWhereCond = "MyField = " & frm!MyField
docmd.openreport strReportName,,,strWhereCond
if err <> 0 then
'OpenReport failed
MyFunction = false
else
MyFunction = true
endif
exit function

Then, call this function from the list box OnDoubleClick event procedure like so:

MyFunction MyListbox.value, Forms!MyFormName

Hope this helps,

Peter De Baets
Peter's Software - http://www.peterssoftware.com
 
Peter D

Thanks for your reply...I have achieved getting the list of Reports...However I am having trouble with the "create a function" part.

I am not sure what I am doing wrong but it keeps telling me the it can't find the macro "MyFunction MyListbox"...

If it's not to much trouble could you assist me further?

Or could you e-mail me an example?

Thanks

Don



[This message has been edited by donbettis (edited 01-02-2002).]
 
Try placing the 'MyFunction MyListbox.value, Forms!MyFormName' part in the VBA-editor. (Click on the dots behind the double_click event and choose the last option)

Albert
 
raindrop3

Thank you...Putting the 'MyFunction MyListbox.value, Forms!MyFormName' as an Event Procedure worked great...

Peter D

Thank You for starting me in the right direction...Without your help raindrop3's suggestion would not have helped me complete this...

I give a round of applause and thanks to the both of you...
smile.gif


Don
 
One last thing...

This is more of a question to broaden my knowledge then is something that I need...

Is there a way of preventing a particular report or reports from being in the list box?

Thanks

Don
Life is Grand when you achieve...
 
I am not sure if this is the only way or if it's a good way however, I figured out that you can name your reports like ~Report1 and it will not show up in the listbox...

When a report is assigned a name starting with "~". The above query skips those names.

Kewl Beans Man...

If this a real bad idea please let me know...

Don
 

Users who are viewing this thread

Back
Top Bottom