UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Toggle Two Subforms, Access 2013    
 
   
komo
post Jul 12 2017, 08:43 AM
Post#1



Posts: 28
Joined: 28-July 16



Hello everyone! I'm still learning access......and for some reason I can't seem to get this to work. I have a toggle button (togEdit) and two subforms (sfrm1 & sfrm2), before toggle button is clicked, sfrm1 is visible. When the toggle is clicked, sfrm2 is visible.

Private Sub TogEdit_Click()
If sfrm1.Visible Then
sfrm1.Visible = False
sfrm2.Visible = True
Else
sfrm1.Visible = True
sfrm2 = False
End If
End Sub

Maybe I'm not doing it right? Should I consider that it's in a form sfrmDetail and within the form there's a tabcontrol (tabPT)? Or it shouldn't matter?
Go to the top of the page
 
GroverParkGeorge
post Jul 12 2017, 09:32 AM
Post#2


UA Admin
Posts: 29,933
Joined: 20-June 02
From: Newcastle, WA


Are you saying that the subform's DO become visible or not? Or that you want them to become visible or not, but this code doesn't do that?

Or are you actually trying to selectively load different subforms in a subform control?

Or, are you trying to change which TAB is visible with the different subforms on those tabs?

Thanks for clarifying the exact problem.

--------------------
Go to the top of the page
 
komo
post Jul 12 2017, 09:58 AM
Post#3



Posts: 28
Joined: 28-July 16



[update] Nevermind! I figured it out! Newbie coding error......sfrm2 name was changed so that caused the issue. I even changed the code a bit and got it to work!!! dance.gif

Private Sub TogEdit_Click()
If sfrm1.Visible Then
me.sfrm1.Visible = False
me.sfrmEdit.Visible = True
Else
me.sfrm1.Visible = True
me.sfrmEdit = False
End If
End Sub


I would be happy to clarify!

sfrm1 is already visible upon load (visible = Yes in the property sheet) and sfrm 2 is not (Visbile = No in the property sheet).

They both reside in pagRes (first tab, so 0?) tab of TabDetails (tab control). TabDetails is in a form frmDetails.


The toggle button is currently in the same area as both sfrms, so in pagRes tab.

Upon load, I ONLY want sfrm1 to be visible (which it is). I need the code to work so that: when user clicks on the toggle button then sfrm1 is no longer visible, but sfrm 2 will be visible instead.

Again, only one sfrm will be visible at a time.
This post has been edited by komo: Jul 12 2017, 10:10 AM
Go to the top of the page
 
GroverParkGeorge
post Jul 12 2017, 10:05 AM
Post#4


UA Admin
Posts: 29,933
Joined: 20-June 02
From: Newcastle, WA


In that case, I would do this differently.

Use a SINGLE subform control.

Instead of toggling visibility, load the two subforms into that subform control as needed.

I.e.

Me.sfrmControlNameGoesHere.SourceObject= "sfrm1"

or

Me.sfrmControlNameGoesHere.SourceObject= "sfrm2"
This post has been edited by GroverParkGeorge: Jul 12 2017, 10:06 AM
Reason for edit: Corrected syntax

--------------------
Go to the top of the page
 
komo
post Jul 12 2017, 10:47 AM
Post#5



Posts: 28
Joined: 28-July 16



Thanks Grover! I'll look into the sourceobject part and see if that makes it better.
Go to the top of the page
 
GroverParkGeorge
post Jul 12 2017, 11:02 AM
Post#6


UA Admin
Posts: 29,933
Joined: 20-June 02
From: Newcastle, WA


Continued success with your project. Please let us know how it works out.

George


.

--------------------
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd July 2017 - 09:48 AM