Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2010
    Location
    California
    Posts
    15

    Unanswered: Need to requery a subform.

    Hello,
    I have a form with a subform. The records in the subform can be "Edited" but new records cannot be added to it within the subform.
    To add records I have created 8 floating fields on the main form that coincide with the subform fields. These floating fields do not have control sources however I have a "Add a Stat" command button that runs a macro to append the data from the floating fields to a table. The macro also turns off the Warnings before the append query runs and then turns it back on after the append query.
    Below is vba in the "Add a Stat" button. After the macro runs I need vba to requery/refresh the data in the subform.

    Could you tell me how to do this?

    Master form Name: frm_DailyStats
    Subform Name: frm_DailyStatsSubform



    Private Sub AddAStatisctic_Click()
    On Error GoTo Err_AddAStatisctic_Click

    Dim stDocName As String

    stDocName = "mcr_DailyStatsAppendMacro"
    DoCmd****nMacro stDocName


    Exit_AddAStatisctic_Click:
    Exit Sub
    Err_AddAStatisctic_Click:
    MsgBox Err.Description
    Resume Exit_AddAStatisctic_Click

    End Sub


    Also, after I refresh/requery the subform (subform only not the master form), I need vba to clear out the data in the 8 floating fields. How would I be able to do that?


    Your help is always appreciated.

    Iram/mcp
    Last edited by iramalvarez; 09-29-10 at 17:42. Reason: Forgot to add a question.
    Iram/mcp

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Forms!frm_DailyStats.frm_DailyStatsSubform.Requery

    Note that frm_DailyStatsSubform must be the name of the subform control on the main form, which could be different than the name of the form itself. You can clear the controls with:

    Me.TextboxName = Null

    or

    Me.TextboxName = ""
    Paul

  3. #3
    Join Date
    Sep 2010
    Location
    California
    Posts
    15

    Requering subform

    Again, you are the man!



    Thanks.
    Iram
    Iram/mcp

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    My head is going to get so big I won't fit through the door!

    Glad it worked for you.
    Paul

Posting Permissions

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