• form refresh (2003)

    Author
    Topic
    #429268

    I have a form that has a button to add a comment. If you click the button it pops up another form in front of the original form to allow the user to add a comment for that user. Once you add the comment and close the record, I’d like the original form to refresh to display the new comment. Is that possible?

    Viewing 1 reply thread
    Author
    Replies
    • #999255

      Is the comment saved in a table? If so, the original form should reflect the change as soon as the record in the popup form is saved.

      • #999262

        Correct, the comment is saved. But the original form is not displaying it unless I click the refresh button I placed on the form, or I should say requery button. I didn’t know if it was possible to do it automatically after the comment form is closed.

    • #999263

      If you need to do something after the popped up form closes (whether that be refreshing if for some reason it’s necessary, or anything else), make the popped up form modal. Execution then won’t continue in the underlying form until the modal form closes or is made invisible, and you can then do me.refresh or whatever else is necessary.

      • #999266

        I’m not sure I’ve heard of me.refresh. Could you explain a bit more, thanks in advance!!

        • #999272

          When you are writing VBA code for a form or report, me is used to point to the form or report that your code is running in. Quoting from the help, “The Refresh method immediately updates the records in the underlying record source for a specified form or datasheet to reflect changes made to the data by you and other users in a multiuser environment.”. Hence me.refresh runs the refresh method for the form your code is running in. See also repaint and requery.

        • #999273

          Make the code that opens the other form look like this (the actual names will be different, of course)

          Private Sub cmdOtherForm_Click()
          On Error GoTo Err_cmdOtherForm_Click

          Dim stDocName As String
          Dim stLinkCriteria As String

          stDocName = …
          stWhereCondition = …

          DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog
          Me.Refresh

          Exit_cmdOtherForm_Click:
          Exit Sub

          Err_cmdOtherForm_Click:
          MsgBox Err.Description
          Resume Exit_cmdOtherForm_Click
          End Sub

          • #1055406

            Make sure that PopUp for the Modal form is also set to NO – having it set to YES seems to ignore the Modal property and just continue running the code which is calling it

    Viewing 1 reply thread
    Reply To: form refresh (2003)

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

    Your information: