Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2

    Question Unanswered: Update form properties after sub form close

    This is sort of related to my earlier post.
    I have form that launches a sub form via a button

    Code:
    Private Sub Edit_AddBtn_Click()
    On Error GoTo Err_Edit_AddBtn_Click
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "New Customer Popup"
        stLinkCriteria = "[CustomerID]=" & "'" & Me![CustomerID] & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit_Edit_AddBtn_Click:
        Exit Sub
    Err_Edit_AddBtn_Click:
        MsgBox Err.Description
        Resume Exit_Edit_AddBtn_Click
    End Sub
    The parent form has on it controls that make command buttons active/inactive based on the contents of a field

    Code:
    Private Sub Form_Current()
    
    If IsNull(Me.EmailAddress) Or Me.EmailAddress = "" Then
        Me.SendMail.Enabled = False
        Else
        Me.SendMail.Enabled = True
    End If
    End Sub
    What I have found is that if the field contents are changed in the sub form, and then the sub form is closed, the controls on the command buttons aren't updated.

    I am using the requery command in the On Close event procedure of the sub form to update the parent form data (which works fine)
    Code:
    Private Sub Form_Close()
        Requery
    End Sub
    However the command button controls are still in the state they were prior to opening the sub form.

    Does anyone know how I "refresh" the parent form to reflect the new state of the form contents.

    Many thanks in advance.

  2. #2
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You can refresh one form from another form's coded actions. You just need to refer to it in the code. From memory, it's something like:
    Code:
    [Forms]![FormNameHere].Requery
    Alternatively, you can try invoking that form's Current() event. Again, working from memory so check the Help file:
    Code:
     Call [Forms]![FormNameHere].Form_Current()
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  3. #3
    Join Date
    Sep 2010
    Posts
    85
    Provided Answers: 2
    [QUOTE=weejas;6594015]You can refresh one form from another form's coded actions. You just need to refer to it in the code. From memory, it's something like:
    Code:
    [Forms]![FormNameHere].Requery
    Great memory, Thanks very much that has fixed it. Funny thing, I never considered the help file!

  4. #4
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    You're welcome!

    Once you know how to read it, the help file can be useful! (It's not as good as the Lotus Notes Developer help file, but you can't have everything...)
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

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