• Change Visible Property

    Author
    Topic
    #461452

    I’ve confused (normally am).

    I have a main form that houses 3 option groups. Each object, when selected, will set the criteria for a query. The third option group (fme_Goal_Options) has 4 options in it, Add, Close, Remove and Edit.

    Also on this form is a tabbed form with 3 tabs and each tab has a subform.

    One of the subforms (sfrm_Edit_Goals_Outcome) has an Option Group (fme_Edit) with 2 options, opt_Edit1 (Remove) and opt_Edit2 (Edit) with visible properties set to FALSE. Both Remove and Edit have different procedures.

    Here’s my problem:

    On the main form, in the 3rd option group (fme_Goal_Options), if the user selects either the 3rd option (Remove) or the 4th option (Edit), sfrm_Edit_Goals_Outcome visible=TRUE and gets the focus.

    What should happen next is:

    If the user selects the REMOVE option, fme_Edit and opt_Edit1 visible=TRUE allowing the user to select it.
    If the user selects the EDIT option, fme_Edit and opt_Edit2 visible=TRUE allowing the user to select it.

    I have the following code in the AfterUpdate Event of fme_Goal_Options:

    Code:
    TabCt.Visible = True
    Select Case fme_Goal_Options
    	Case 1 'Add a Goal
    		Me.pgGoals.Visible = True
    	Case 2 'Close a Goal
    		Me.pgSelectedGoals.Visible = True
    		sfrm_Selected_Goals.SetFocus
    	[b]Case 3 'Remove a Goal[/b]
    		txtER = 1
    		pgSelectedOutcomes.Visible = True
    		pgSelectedOutcomes.Caption = "Remove Goal"
    		pgSelectedOutcomes.SetFocus
    		sfrm_Edit_Goals_Outcome.Visible = True
    		sfrm_Edit_Goals_Outcome.SetFocus
    	[b]Case 4 'Edit a goal[/b]
    		txtER = 2
    		pgSelectedOutcomes.Visible = True
    		pgSelectedOutcomes.Caption = "Edit Goal"
    		pgSelectedOutcomes.SetFocus
    		sfrm_Edit_Goals_Outcome.Visible = True
    		sfrm_Edit_Goals_Outcome.SetFocus
    End Select

    In the OnLoad Event of sfrm_Edit_Goals_Outcome, I have the following code:

    Code:
    If Forms!frm_Goal_Information.txtER = 1 Then 'True=Remove
    	For Each ctr In Me.Controls
    		If ctr.Tag = "Remove" Then ctr.Visible = False
    		If ctr.Tag = "Edit" Then ctr.Visible = True
    	Next ctr
    Else
    	For Each ctr In Me.Controls
    		If ctr.Tag = "Edit" Then ctr.Visible = False
    		If ctr.Tag = "Remove" Then ctr.Visible = True
    	Next ctr
    End If

    The problem is, fme_Edit and its 2 options as don’t change as they should based on the code above. i.e. if Remove is selected, then opt_Edit1 should be visible, if EDIT was selected, then opt_Edit2, should be visible.

    Could someone please take a look at it and let me know what I’ve done wrong.

    I really appreciate any assistance on this.

    Viewing 0 reply threads
    Author
    Replies
    • #1170910

      The On Load event of the subform does not occur when it is made visible, but when the main form is loaded, whether the subform is visible or not. So the code you wrote is not executed when the subform is made visible.
      You’ll have to show/hide controls on the subform from your main form code.

      • #1170927

        The On Load event of the subform does not occur when it is made visible, but when the main form is loaded, whether the subform is visible or not. So the code you wrote is not executed when the subform is made visible.
        You’ll have to show/hide controls on the subform from your main form code.

        Thanks Hans,

        That did the trick. Much appreciated.

    Viewing 0 reply threads
    Reply To: Change Visible Property

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: