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