Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    New Zealand

    Unanswered: Requery or Refresh current form Using VBA

    I have a form that has a number of child subforms attached to it.
    All the subforms are based on queries.
    If a user edits the form, and portions of the subforms, only by printing the active selection will all the forms update, and the screen refresh to show the changes.
    One subform looks at invoices, if a new price is added there is a subform which sums the new price to the old. Only when the form prints does the whole lot update.
    I have tried [Forms]![Works Card].Requery
    but end up right at the start of the database.
    If I try [Forms]![Works Card].Requery acSelection it crashes with can't find a feild number 1.
    Is there a way to Requery or refresh a current selection or requery the query that the subforms are looking at. I have a Save button and was hoping to run the update from there.
    Any suggestions would be appreciated.
    Thanking in Advance

  2. #2
    Join Date
    Jul 2002
    Think of a subform as an ordinary control on a form. I guess [Works Card] is the name of a subform. The syntax
    [Forms]![Works Card].Requery
    tries to requery the form [Works Card], not the control [Works Card]

    To requery the subform, use:

    Forms("MainFormName")("Works Card").Requery


    Forms![MainFormname]![Works Card].Requery



  3. #3
    Join Date
    Nov 2012
    I tried Dan's code, I can't seem to get it to work.

    I reloaded the subform's SourceObject, thereby forcing a reload, and I confirmed this with the sub forms Open Event.

    Here's my code, refer to the screen shot.

    This is currently in scope of the Main Form

    Me.Controls("SubFormControlName").SourceObject = ""
    Me.Controls("SubFormControlName").SourceObject = "sfrmSubForm"

    If you are out of scope, but the Main Form is loaded.

    Forms("frmMain").Controls("SubFormControlName").So urceObject = ""
    Forms("frmMain").Controls("SubFormControlName").So urceObject = "sfrmSubForm"

    Remember that the Sub Form's Control's name on the Main Form could be different than the Actual Sub Form. Refer screen shot.
    Attached Thumbnails Attached Thumbnails SubFormSourceObject.JPG  
    Last edited by ddcruz; 11-01-12 at 17:30. Reason: requires review

Posting Permissions

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