drop down list for forms or reports (or both)?

B

_Bigred

Is there a way that I can create a drop down list (drop down box) that would
give a listing of all the forms and/or reports in the database - so that
when the user click the desired one from the list it opens that form or
report?

I'm creating the db in access2000 but it will ultimately be deployed on a
single machine using access2003.

TIA,
_Bigred
 
T

tina

you could create a table to hold the names of the forms and reports in the
database, manually adding/deleting records as appropriate - and base your
combo box RowSource on that table. or you could dynamically build a value
list for the RowSource, by looping through the AllForms and AllReports
collections of the CurrentProject object.

dynamically building the list would ensure that it's always up-to-date. but
if your database has subforms and/or subreports, they would also be included
in the list since they're objects in their own right, apart from their
"parent" objects. also, if you're following standard naming conventions in
your db, such as using "frm" and "rpt" prefixes and disallowing spaces and
special characters, then the dynamic list is going to be pretty ugly and
perhaps hard for your user to choose the correct form or report to open.

using a table has the drawback of needing to be updated each time a
form/report is created/deleted. on the other hand, you can decide what
objects to list, avoiding the problem of having subforms/subreports listed
separately. and you can include a field in the table for "nice" names for
the form/report objects, so the user doesn't see the actual object names.

personally, i would go with the table, as

tblObjects
ObjectName (primary key, the "real" name of the form/report in the database
window)
ObjectDisplay (the "nice" name to show the user in the combo box list)
ObjectType ("form" or "report")

in the form that has the combo box, add code to the combo box's AfterUpdate
event, that checks first to see if a name was selected from the list. if so,
then the code can check the ObjectType column of the RowSource, and run the
OpenForm or OpenReport command appropriately, referring to the ObjectName
column of the RowSource (should be the bound column) to get the name of the
object.

hth
 
J

John Nurick

The simplest way is to use a query on the hidden system table
MSysObjects as the RowSource of the combobox, e.g.:

SELECT Name FROM MSysObjects WHERE Type=-32768 ORDER BY Name;

For reports, use -32764.
 

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