Is there a way to make a Database on startup, prompt the user to choose a form to open? (1 Viewer)

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
Just wondering if there is a way to make a database startup with a welcome message box and button to open a certain form. This means there is no form set to default open on startup. Let's say there are only 2 forms for now.

Will it be an AutoExec / Macro / VBA thing? Or is there a simpler way..? And if yes, how would I go about doing a macro for it.

So the process should run like this:

1- Opens Database
2- Welcome message box pops up, with the request to choose a form to open (if this has to be two separate steps that's fine too)
3- Clicks the button for that form
4- Form Opens
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:37
Joined
Oct 29, 2018
Messages
21,358
Could you make the welcome box actually a form, so you can add buttons and code to do what you want?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 03:37
Joined
Feb 28, 2001
Messages
27,001
I always used a "switchboard" or "dispatcher" type of form. It was the opening form and when it popped up, it showed me buttons for the forms I was able to launch, one button per form. This opening form never closed but allowed any other form to move to the top, thus hiding the opening form while the other form was in use.
 

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
I always used a "switchboard" or "dispatcher" type of form. It was the opening form and when it popped up, it showed me buttons for the forms I was able to launch, one button per form. This opening form never closed but allowed any other form to move to the top, thus hiding the opening form while the other form was in use.
I didn't consider a switchboard form, that's really helpful actually. Thank you sir.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:37
Joined
May 7, 2009
Messages
19,169
sample form.
 

Attachments

  • sampoline.zip
    25.1 KB · Views: 225

isladogs

MVP / VIP
Local time
Today, 08:37
Joined
Jan 14, 2017
Messages
18,186
Another idea would be to have a start/welcome form with a combo box listing various forms for the user to choose from.
When a selection is made. open that form
If the user can select from any of the database forms, the row source used for the combo can be automatically created using the MSysObjects system table:
Code:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type=-32768;

EDIT: I see @arnelgp has used a similar idea but with a listbox and creating a separate table to list the forms to select from
 

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
Another idea would be to have a start/welcome form with a combo box listing various forms for the user to choose from.
When a selection is made. open that form
If the user can select from any of the database forms, the row source used for the combo can be automatically created using the MSysObjects system table:
Code:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE MSysObjects.Type=-32768;

EDIT: I see @arnelgp has used a similar idea but with a listbox and creating a separate table to list the forms to select from
Oh yes I see what you mean, cheers for that!
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:37
Joined
Feb 19, 2002
Messages
42,981
Here's a custom switchboard and a modified Access switchboard along with some simple security
 

Attachments

  • SwitchboardForm20201018c.zip
    1.6 MB · Views: 224

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
Here's a custom switchboard and a modified Access switchboard along with some simple security
Wow this is very in depth Pat. I was actually after some help with creating User level security but wasn't clear on how to start. Thanks for the extra initiative.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:37
Joined
Feb 19, 2002
Messages
42,981
The security in this example is simplistic and tied specifically to forms and actions on forms such as add/change/delete.

Hope you find it useful.
 

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
sample form.
Sorry to bring up this post again, just ran into an issue. So I used this template as a means to create a Switchboard for my database. I made 2 databases. One of them had no issues and works like a charm. The other one which has the exact same Switchboard (but different names for the list box and buttons). But whenever I try open the first form on the list, I am met with a run-time error 2501 openform cancelled. But when I select the next form down the list, it works.

Here is the code that was written for the Switchboard:

Code:
Private Sub cmdOpenForm_Click()
If Me.txtSelect.ListIndex = -1 Then
    MsgBox "Please select a form to open."
    Me.txtSelect.SetFocus
    Exit Sub
End If
DoCmd.OpenForm Me.txtSelect.Column(2)
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

txtSelect is my List Box
The code is running under my open form button_click

I can understand if the code didn't work for both my databases, but it is working for one and not working for the other. Both databases have the 2 forms. If that helps.

EDIT: So seems like my database corrupted somewhere. I exported my database to a blank one. All functions work correctly again. Not sure why that happened. But I guess as long as it's working, then no problem. Would still like to know if there is a reason why that happened. Thanks.
 
Last edited:

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:37
Joined
Aug 30, 2003
Messages
36,118
Sounds like your problem is with the form, not the code. Can you open that first form from the navigation pane?
 

Sampoline

Member
Local time
Today, 19:37
Joined
Oct 19, 2020
Messages
161
Sampoline,
Are you using my sample?
Hi Pat

Yes I ended up using your sample to create my switchboard. Not too sure what happened with my previous database, but seems like all is fine now that I exported the database to a new one and deleted the old one.
 

Users who are viewing this thread

Top Bottom