Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    form refresh (2003)

    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?

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

    Re: form refresh (2003)

    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.

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form refresh (2003)

    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.

  4. #4
    Star Lounger
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form refresh (2003)

    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.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form refresh (2003)

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

  6. #6
    Star Lounger
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form refresh (2003)

    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.

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

    Re: form refresh (2003)

    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

  8. #8
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Warwick, Warwickshire, England
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: form refresh (2003)

    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

Posting Permissions

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