判断应该在前面的,不去理解,别人帮你写再多代码,也是没有用的。
If e.DataCol.name = "日期" Then
If e.DataRow.IsNull("日期") = False Then
Dim dt As Date = e.DataRow("日期")
If dt.Day < 26 Then
dt = dt.AddMonths(-1)
End If
Dim dt1 As Date = New Date(dt.Year,dt.Month,26)
Dim dt2 As Date = dt1.AddMonths(1).AddDays(-1)
Dim Filter As String
Filter = "日期 >= #" & dt1 & "# And 日期 <= #" & dt2 & "#"
Tables("原料入库").Filter = Filter
End If
End If