Selecting which form to open

  • Thread starter Thread starter James Duart Maclaine
  • Start date Start date
J

James Duart Maclaine

Hi,

I'm relatively inexperienced in using Access, and have very limited
programming skills... however all is going well so far thanks to forums such
as this... until now

The database I'm creating will have approx. 20 forms from which the user
will select 1 to open.

The only way I've come up with to give the user the choice of which form to
open is through having 20 Command buttons, but I'm sure there must be a
better way. I was hoping to use a drop-down list (like a combo box where
the values are the names of the forms, and selecting them will open that
form) or something similar.

Any advice greatly appreciated.

Ben
 
Using a combo box would be better. Create a table that has the names of the
forms and use that table as the row source of the combo box. Then you could
use this code on the combo box's AfterUpdate event:

Private Sub cboBoxName_AfterUpdate()
DoCmd.OpenForm Me.cboBoxName
End Sub
 
James,
There are a couple of ways to get a list of all the forms in the database.
Here is one.

Add a List (or Combo) Box to the Switchboard form.
Set it's RowSource Type to:
Table/Query
Set it's Columns Count to 1
Column Widths to 1"
Set it's RowSource to:

SELECT MSysObjects.Name, MSysObjects.Type FROM MSysObjects WHERE
(((MSysObjects.Type)=-32768)) ORDER BY MSysObjects.Name;

If you wish to use a command button, place this code in the button's click
event.
DoCmd.OpenForm Me!ListBoxName

Select the form name in the List/Combo box.
Click the command button.
Make sure your form names are 'user friendly'.
 
Thanks Ken... it's working!!!!
Ken Snell said:
Using a combo box would be better. Create a table that has the names of the
forms and use that table as the row source of the combo box. Then you could
use this code on the combo box's AfterUpdate event:

Private Sub cboBoxName_AfterUpdate()
DoCmd.OpenForm Me.cboBoxName
End Sub
 
I will actualy stick my neck out and say that puttign 10, or 12 buttions on
a form to launch parts of teh appction is not that bad.

I do think that 20 buttions is starting to get a bit large.

What I would do is try group the buttion into several areas. So, perhaps
your first form only have 4, or 5 major catagoreis, and then you launch
ANOTHER form with only 4 or 5 buttions. That way, you can branch out from
the main form. Each of these addtional forms would thus only hvae 4 or 5
buttions.


So:
main-form
|
FormCat1
is starting to get up there, but
 
Back
Top