If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
SubForm Visibility
Hello-
I would like to design a form for data entry which, when a button is clicked, a specific sub-form is loaded/visible. I have 2 sub-forms that need to be completed, however I want the user to be able to toggle between the two. However, I don't want the user to be able to see the sub-form that they do not need to use until they are ready to use it. So- I'd like my toggle button to make either the one form visible, OR the other form visible, but not both at the same time. Thanks. |
#2
|
|||
|
|||
SubForm Visibility
I use buttons on my main form that does the same thing that I think you want:
For the "on click" event of one button I have: Private Sub buttonname_Click() Forms![Main Menu]![Hours Menu].Visible = True Forms![Main Menu]![Reports Menu].Visible = False End Sub For the "on click" event of the other button I have: Private Sub buttonname_Click() Forms![Main Menu]![Hours Menu].Visible = True Forms![Main Menu]![Reports Menu].Visible = False End Sub I hope this helps! "Julia CHP" wrote: Hello- I would like to design a form for data entry which, when a button is clicked, a specific sub-form is loaded/visible. I have 2 sub-forms that need to be completed, however I want the user to be able to toggle between the two. However, I don't want the user to be able to see the sub-form that they do not need to use until they are ready to use it. So- I'd like my toggle button to make either the one form visible, OR the other form visible, but not both at the same time. Thanks. |
#3
|
|||
|
|||
SubForm Visibility
the "true" and "false" should be the other way round for the second button. "Julia CHP" wrote: Hello- I would like to design a form for data entry which, when a button is clicked, a specific sub-form is loaded/visible. I have 2 sub-forms that need to be completed, however I want the user to be able to toggle between the two. However, I don't want the user to be able to see the sub-form that they do not need to use until they are ready to use it. So- I'd like my toggle button to make either the one form visible, OR the other form visible, but not both at the same time. Thanks. |
#4
|
|||
|
|||
SubForm Visibility
You could set the Visible property of one subform control to True and of the
other to False, then use code like this in a command button's Click event: Me.SubformControl1.Visible = Not Me.SubformControl1.Visible Me.SubformControl2.Visible = Not Me.SubformControl2.Visible You could also put one subform on top of the other. Set the visible property of one to True and the other to False. If SubformControl2 has the visible property set to False, your command button code could be: Me.SubformControl2.Visible = Not Me.SubformControl2.Visible There are other options too, depending on your needs, but the syntax is the same. Use your actual subform control names, which may be different from the form names if you created the subforms separately. To see the name of the subform control, click the very edge of the subform so that small rectangular "handles" appear at the corners and in the middle of each edge, then click View Properties. The property sheet that appears will say Subform/Subreport followed by a name that also appears on the Other tab of the property sheet. This is the name you need to use in the command button code. Or you many find that a tab control (with file tabs like the property sheet) gives you what you need. "Julia CHP" wrote in message ... Hello- I would like to design a form for data entry which, when a button is clicked, a specific sub-form is loaded/visible. I have 2 sub-forms that need to be completed, however I want the user to be able to toggle between the two. However, I don't want the user to be able to see the sub-form that they do not need to use until they are ready to use it. So- I'd like my toggle button to make either the one form visible, OR the other form visible, but not both at the same time. Thanks. |
#5
|
|||
|
|||
SubForm Visibility
Scuba's method will work.
There is another approach I use to allow the main form to load faster. That is to leave the source object and Link Master Fields and Link Child fields properties blank and the visible property of the subform control No. Then in the After Update event of the toggle button: Dim strSource As String Dim strMaster As String Dim strChild As String If Me.opgMyOption Group = 1 Then strSource = "frmSomeForm" strMaster = "SomeMainField" strChild = "SomeSubField" Else strSource = "frmAnotherForm" strMaster = "SomeOtherMainField" strChild = "SomeOtherSubField" End If With Me.MySubFormControl .SourceObject = strSource .LinkMasterFields = strMaster .LinkChildFields = strChild .Visible = True End With If the subforms are of different sizes, you can include the Height, Width, Left, and Top properties to position and size the subform the way you need it. If you want to start fresh with no subform showing for each record, use the form Current event: Me.MySubFormControl.Visible = False Me. "Julia CHP" wrote: Hello- I would like to design a form for data entry which, when a button is clicked, a specific sub-form is loaded/visible. I have 2 sub-forms that need to be completed, however I want the user to be able to toggle between the two. However, I don't want the user to be able to see the sub-form that they do not need to use until they are ready to use it. So- I'd like my toggle button to make either the one form visible, OR the other form visible, but not both at the same time. Thanks. |
Thread Tools | |
Display Modes | |
|
|