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

    Hiding subform (Access03)

    After a refresh button is clicked I want to have a subfrm disappear. I get a message that I can hide a form that has the focus. I tried setting the focus to a text box on the main form. Then do the refresh action and then hide. I see the cursor jump to then leave the lastname field. I also had it below the DoCmd line.

    Me.LastName.SetFocus
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    Me!frmSalary.Form!subfrmSalary.Visible = False

    Thank you for any ideas.

    Fay

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Hiding subform (Access03)

    Are you trying to hide subfrmsalary, which is a subform of frmSalary, which is itself a subform of some other main form ?

    Me!frmSalary.Form!subfrmSalary.Visible = False

    Which form is the refresh command button on? Which form is being refreshed?

    You can refresh with the refresh method, so you could put the command button on the main form and try

    Me!frmSalary.Form.refresh
    Regards
    John



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

    Re: Hiding subform (Access03)

    Thanks for responding

    Want to hide subfrmSalary. Yes it is a subfrm of frmSalary. They are on a tab control located on the main form frmEmployees.
    The button is on frmEmployees. When pressed it updates everything.
    The Me!frmSalary.Form.refresh did not work.

    Any other ideas?

    Fay

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Hiding subform (Access03)

    Have you looked into any code you might have that is automatically moving the focus to the subform you are trying to hide?

    What happens if you click the mouse in the lastname field? Does the focus stay there?

    Put in this line of code before the line that tries to hide the subform. It will tell you what control has the focus.
    MsgBox (Screen.ActiveControl.Name)
    Regards
    John



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

    Re: Hiding subform (Access03)

    the refresh button cmdRefresh.

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Hiding subform (Access03)

    Does your code now read:

    Me.LastName.SetFocus
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
    msgbox(screen.activecontrol.name)
    Me!frmSalary.Form!subfrmSalary.Visible = False


    and the message box displays "cmdrefresh" and cmdRefresh is definetely on the main form and not the one you are trying to hide?

    When I try the same code as this it works OK, so I don't know what is going on for you.

    why does the focus move from lastname back to the command button?
    Why does having the focus on the command button stop the hiding of the form?

    I don't know the answer to either question.
    Regards
    John



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

    Re: Hiding subform (Access03)

    I went back in and used your code. That went back to the LastName control. After clearing that message I still got the message that I couldn't hide the the control that has the focus.

    Thanks for coming back.

    Fay

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hiding subform (Access03)

    See if it works if you set the focus to LastName AFTER refreshing:

    Me.Refresh
    Me!LastName.SetFocus
    Me!frmSalary.Form!subfrmSalary.Visible = False

    If that doesn't work either, insert a line to set the focus on the frmSalary subform to something other than subfrmSalary:

    Me.Refresh
    Me!LastName.SetFocus
    Me!frmSalary!SomeControl.SetFocus
    Me!frmSalary.Form!subfrmSalary.Visible = False

    where SomeControl is the name of a control on frmSalary.

Posting Permissions

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