Requery Subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ElizabethLOng
    New Member
    • Aug 2012
    • 12

    #16
    Sorry it took me sometime to reply, still trying to work out my code. I am using MS Access 2007. My code can filter records in the subform based on the date range entered in the main form. The problem with my code after filtering the subform it only refreshed the first record, is there a way to refresh all the filtered records? I need to constantly change the quantity at a certain date range in the subform based on the revised quantity in the mainform. Thanks for your help.

    Code:
    Private Sub Image87_Click()
        Dim strFilter As Variant
        Dim strSDate As String
        strSDate = Me.SDate
        Dim strEDate As String
        strEDate = Me.EDate
          
        'check sdate
        If Not IsDate(Me.[SDate]) Or Not IsDate(Me.[EDate]) Then
            MsgBox "Valid dates must be entered"
            Exit Sub
        End If
        If Me.[EDate] < Me.[SDate] Then
            MsgBox "End date must be later than start date"
            Exit Sub
        End If
    
        'if both sdate and edate are valid, run filter
        strFilter = "[sfmDDate] BETWEEN " & Format(Me.SDate, "\#mm\/dd\/yyyy\#") & _
                    " AND " & Format(Me.EDate, "\#mm\/dd\/yyyy\#")
        Forms!FormName!SubformName.Form.Filter = strFilter
        Forms!FormName!SubformName.Form.FilterOn = True
        Forms!FormName!SubformName.Form!SubformControlName = Me!FormRevisedQTY.Value
    
    ExitSub:
    
    End Sub

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #17
      try inserting: Forms!FormName! SubformName.For m.Requery after line 23 of the posted code.

      You'll also find the following insight article (and the refered to cascade) to be of interest: http://bytes.com/topic/access/insigh...filtering-form
      ... http://bytes.com/topic/access/insigh...mbo-list-boxes
      and the overall map is at the bottom of this page "Microsoft Access / VBA Insights Sitemap" scroll down there... TONS and TONS of information!

      Comment

      Working...