+ Reply to Thread
Results 1 to 4 of 4

Thread: set .Visible = True on Subform, From Another Subform

  1. #1
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    set .Visible = True on Subform, From Another Subform

    I have a "master" form which contains a few subforms that are shown or hidden depending on the context of the master form (which options are selected, etc.).

    In one subform, the user enters audit information. I attempting to make the AfterUpdate subroutine set on that subform to hide itself and show another subform. There is a button on the master form that does just this, but I want it to do it automatically when the user updates the record. I just can't seem to get it to work, though.

        Dim Resp As Variant
        
        If Not IsNull(Me.Date_of_Doc_Audit) And Not Me.Post_Closing_Memo_Sent Then
            Resp = MsgBox("Were there Post Closing Exceptions?", vbYesNoCancel, "Post Closing Memo")
            
            Select Case Resp
            
            Case vbYes
                Call Me.Parent.cmdPostClosingMemo_Click
            Case vbNo
                
            Case vbCancel
            
            End Select
            
        End If
    Me.Parent.cmdPostClosingMemo_Click looks like this:
    Public Sub cmdPostClosingMemo_Click()
        Me.lblTitle.Caption = "Post Closing Exceptions"
        Me.frmDocumentation_sub.Visible = False
        Me.frmInsuranceException_sub.Visible = False
        Me.frmDocException_sub.Visible = False
        Me.frmTaxException_sub.Visible = False
        Me.frmPostClosingMemo_Sub.Visible = True
        
        Me.frmPostClosingMemo_Sub![Date of Memo].ColumnWidth = -2
        Me.frmPostClosingMemo_Sub![Document 1 Type].ColumnWidth = -2
        Me.frmPostClosingMemo_Sub![Term on Document 1].ColumnWidth = -2
        Me.frmPostClosingMemo_Sub![Document 2 Type].ColumnWidth = -2
        Me.frmPostClosingMemo_Sub![Term on Document 2].ColumnWidth = -2
    End Sub
    The cmdPostClosingMemo_Click subroutine runs, because the lblTitle lable changes, but the subforms do not hide/unhide.

    I've played around with the syntax, done oodles of Google searches, etc. Can someone help me out?

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: set .Visible = True on Subform, From Another Subform

    I'm not too familiar with the use of subforms, but does it work if you set the focus on the PostClosingMemo subform first?

    Is there an error, or does it just not do what you want it to?
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Guru Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,249

    Re: set .Visible = True on Subform, From Another Subform

    Me.Parent.SetFocus does not work. Neither does Me.Parent.cmdPostClosingMemo.SetFocus. It changes the lblTitle.Caption, but just doers not hide/unhide the subforms.

    Looking at this site (http://access.mvps.org/access/forms/frm0031.htm) I am thinking maybe it is not possible to control a subform from another subform. The "To refer to a subform control property, like SourceObject" section has N/A if you are on the parent form or any subform. If this is the case, I can't imagine what the reason is. Should I SetFocus on another for briefly and have that form's "SetFocus" event do the work?

  4. #4
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: set .Visible = True on Subform, From Another Subform

    Can you just avoid the descendant issue by jumping to the form by name?:

    [Forms]!["Parent"_Form].[frmPostClosingMemo_Sub].SetFocus
    The subform would have to be visible before you can set the focus.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0