Dynamic Subform Help!

J

jdtyler

I am trying to have a single form that provides the main interface to my
database that then calls on other forms (displayed as subforms) for actual
content. I need to have a macro that is run when a user cliks a menu to
display one of these subforms. I understand that I need to use SourceObject
but can't seem to get this to work.

So I have (for instance) the following forms:

MainForm

Subform1

Subform2

Subform3

I need to get a macro to change which of the 3 subforms are displayed within
MainForm.

Any help?

Thanks in advance!
 
A

Al Campagna

jd,
Well, starting out with all subforms set to Visible = No, upon a button (cmdShowSub1)
you would show sub1 and hide sub2 & sub3. Even though they may be hidden already, you can
never be sure what state the subs were in before a button click... so... always show the
one indicated by the button, and hide both the others.
Private Sub cmdShowSub1_Click()
Sub1.Visible = True
Sub2.Visible = False
Sub3.Visible = False
End Sub

But, a Tab Control will accomplish the same thing, much more simply...
Each Tab Page can hold an individual subform, and the user just has to click the
appropriate Page tab to display that subform.
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
T

tina

well, "when a user clicks a menu" doesn't give me any idea of how you have
this "menu" set up. i'll describe how you can do it with a listbox control.

i'll assume the listbox control is named "lstSubs" and shows the following
three options in the list:
Subform1
Subform2
Subform3

add code to the control's AfterUpdate event procedure, as

Me!SubformControlName.SourceObject = Me!lstSubs

if you can't get it to work, post back with more details of what you're
using as a "menu".

hth
 

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