Using a form to select a form to open (1 Viewer)

sumdumgai

Registered User.
Local time
Today, 17:32
Joined
Jul 19, 2007
Messages
453
I want to restrict users to only a form view when opening a database. There are several forms that the user may use. I can't figure out the VBA I should use to allow the user to choose a form name from the 'Select_Form' form and then open the form they selected. I've tried 'After Update' event and I can get the name of the form selected, but I can't pass that selection to a module that would open that form.


In my 'After Update' code, I have:
Code:
MsgBox Forms!Form_SelectF!Form_Name
which displays the form selected.


In my module, I have:
Code:
            DoCmd.RunMacro ("Open_Form_SelectF")            
            MsgBox Forms!Form_SelectF!Form_Name
The last line 'Msgbox' gives an error 'null' value



Would appreciate any help.


Thanks.
 

Micron

AWF VIP
Local time
Today, 17:32
Joined
Oct 20, 2018
Messages
3,478
Forms!Form_SelectF!Form_Name
Is this form open that moment? If not, you can't refer to it that way. Maybe I am missing the way things are, but I did read at least 2x...:eek:
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:32
Joined
Aug 30, 2003
Messages
36,125
Would this work?

DoCmd.OpenForm Forms!Form_SelectF!Form_Name
 

sumdumgai

Registered User.
Local time
Today, 17:32
Joined
Jul 19, 2007
Messages
453
Thanks Micron.



In Autoexec, I want to open a form that has a listbox that lists available forms by their name. I want the user to then select one of the listed forms and then open the selected form. Not sure where the code goes to open the selected form.
 

sumdumgai

Registered User.
Local time
Today, 17:32
Joined
Jul 19, 2007
Messages
453
Thanks pbaldy. Your suggestion didn't work, at least where I used it in the module.
 

sumdumgai

Registered User.
Local time
Today, 17:32
Joined
Jul 19, 2007
Messages
453
This works in 'AfterUpdate':
Code:
    Select Case Me.Form_Name
    Case "Form 1"
       DoCmd.OpenForm "Form_1"
    Case "Form 2"
       DoCmd.OpenForm "Form_2"
    End Select
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 14:32
Joined
Aug 30, 2003
Messages
36,125
Glad you got it sorted. Looks like the form names differ from what the control has. My code should have worked if they were the same.
 

Users who are viewing this thread

Top Bottom