Command button to switch between subforms (embedded) (1 Viewer)

Junkee Brewster

Registered User.
Local time
Today, 20:41
Joined
May 21, 2005
Messages
33
I need command button(s) to switch between subforms on a mainform in only one subform window (one subform already set as default). So in other words, I don't want a command button to open up new forms (I know how to do that); I need to minimize the amount of subforms and forms I have open by only having a few major user interfaces.

Sorry for the terse beginning, I thought ^ would help when u run your mouse over the topic and get the first line of the message so ppl knew what I was on about instead of "hello please help me" hehe. Now for greetings: Hi folks, great site, helped me silently for awhile but now I gotta ask for help.

In the scheme of things, I'm still a newb; I've learnt a whole lot real fast, but I need a "short cut". I've looked in the forum and found one relevant message but it was a little too brief (a higher knowledge level than mine).

The message I referred to earlier mentioned "toggling visibile property" (?) and also "setfocus" - I need that clarified and fleshed out please.
*Note* My Visual Basic: IsNull, Else If Not IsNull (Me.ShockingandBasic). Me.Junkee Brewster = learns really fast when shown.
I know a bit about command buttons and I don't usually have problems with forms or anything like that, but I cannot conceptially understand how I can have extra subforms linked to show up in my default subform window

I would rain diamonds (I'm working on it) on the person who has the time/patience to give a little "step-by-step" dialogue (including how to chuck in those extra subforms); don't be afraid to patronize me, spell it out if you like (err, please do infact) :) Thankyou kindly.
 

gizzu

Registered User.
Local time
Today, 13:11
Joined
May 20, 2005
Messages
28
well, you don't have to have the sub forms show up in the same sub form window. Just have two sub form windows with the same Left, Top, Width and Height properties. let say you name the subform controls sf1 and sf2. set the visibility to true for sf1 and false to sf2. then have a command button togglesubform. set the caption for togglesubform to "show sf2". then do something like this in the OnClick event for togglesubform:

if sf1.visible then
sf1.visible=false
sf2.visible=true
togglesubform.caption="show sf1"
else
sf1.visible=true
sf2.visible=false
togglesubform.caption="show sf2"
endif
 

MarkK

bit cruncher
Local time
Today, 04:11
Joined
Mar 17, 2004
Messages
8,186
What I like to do if I have a few subforms on one main form is to navigate between them using a tab control.
Place tab control (tab1) on main form (frm1). Set the BackStyle property of tab1 to transparent. Create ONE subform control (sfm1) on the main form and put in UNDER the transparent tab1.
Now, in the tab1_Change() event handler change out the SourceObject of sfm1.
Code'll look a little like this...

Code:
Private Sub tab1_Change()
   Select Case tab1.Value
      Case 0
         sfm1.SourceObject = "frmSomeSubform"
      Case 1
         sfm1.SourceObject = "frmSomeOtherSubform"
      Case 2
         sfm1.SourceObject = "frmSomeFinalSubform"
   End Select
End Sub
Change the subform from code, maybe in the Open event of your form using...

Code:
   tab1.Value = 2
   tab1_Change
 

Users who are viewing this thread

Top Bottom