Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    displaying subform (Access03)

    I have a main form (frmEmployees) that has a sub form called frmResignRehire, this subform is on a multipaged tab control. On that sub form is a control called TypeofAction. Then there is a subform on frmResignRehire called subfrmResignRehire. This last subform I do not want to be displayed when the frmEmployees is opened. It should be displayed when the TypeofAction has been updated. So I want to make subfrmResignRehire visible property to be false until the TypeofAction control after update event occurs. So I inserted the following into the frmEmployees open event

    Forms!frmEmployees!frmResignRetire.Form!subfrmResi gnRetire.Form.Visible = False

    It doesn't work. What am I missing?

    Thank you. Fay

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: displaying subform (Access03)

    To hide a subform, you set the visible property of the subform control on the parent form, not the visible property of the subform itself. In other words, the syntax is something like this: <code>Forms!frmEmployees!frmResignRetire.Visible = False</code>. The exact syntax depends on where you happen to be running the code. If it's in the parent form, you can simply use <code>Me!frmResignRetire.Visible = False</code>. If you need to change the setting from another subform on the parent form, you'll need to use the full reference or <code>Me.Parent!frmResignRetire.Visible = False</code>.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: displaying subform (Access03)

    Hi Charlotte thank you for your reply.

    I have be try to convince this thing to work and not getting there with your previous note.

    Main form frmEmployees
    1st subform frmResignRetire
    2nd subform subfrmResignRetire *this is the one that should not be visible when the frmEmployees form is opened.

    I am trying to put the code in the frmEmployees open event.

    I am losing the argument with Access.

    Fay

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: displaying subform (Access03)

    Then set the subform control on frmResignRetire to visible = false. That will atuomatically hide the sub-subform until you make it visible. Setting the visiblity from the parent form doesn't make sense if the sub-subform is linked to fields on the subform.

    In the code behind frmResignRetire, put the code to set visible = true when the condition you want to test for is true. You shouldn't need to put anything in the parent form. The general rule of thumb is to put operations like this as close to the object as possible, meaning in this case, the parent subform. That's about as helpful as I can be without more information or a sample of the forms and the underlying tables/queries to look at.
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: displaying subform (Access03)

    I have been away from this project and it still hasn't figured itself out yet nor have I. I keep getting runtime error 2465. can't find field subfrmResignRetire. If you change the Type of Action control and error message displays. I would appreciate any help. Thank you.
    Attached Files Attached Files

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: displaying subform (Access03)

    Fay,

    I suspect your problem is that you're trying to refer to the name of the subform object, but that isn't the name of the subform control, either on the parent form or on the subform. Your parent form is named frmEmployees. It contains a subform control named [frmResign-Retire], which has the form frmResignRetire as its source object. The subform frmResignRetire contains another subform control named [Resign-Retire], which has the subform subfrmResignRetire as its source object. When you want to refer to these objects, you have to use the name of the controls, not the actual name of the objects in those controls. I would also recommend that you avoid characters like the hyphen in your object names. VBA code can't handle characters like that, so you get some strange results unless you are careful to always put them in square brackets. I fixed your problem for you in the code behind frmResignRetire. You had this routine:

    <pre>Private Sub TypeOfAction_AfterUpdate()
    Me!subfrmResignRetire.Form!StartDate.Visible = True
    End Sub</pre>


    I corrected it to this:

    <pre>Private Sub TypeOfAction_AfterUpdate()
    Me.[Resign-Retire].Form!StartDate.Visible = True
    End Sub</pre>

    Attached Files Attached Files
    Charlotte

  7. #7
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: displaying subform (Access03)

    How stupid can you get. I keep looking at the listing in the Project Explorer window and checking the spelling there. I thought I had looked at the name also. My dad always told me if an electrical item didn't work see if it is plugged in. And I had thought I had applied the same concept but with spelling here. Thanks for finding the obvious. I will remove the hyphen. Thanks! Fay

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •