2016年1月8日 星期五

Access VBA : Changing Subform RecordSource Programmatically


Changing Subform RecordSource Programmatically



Private Sub Command37_Click()

  Dim strFilter As String
   strFilter = ""
  child_qry10.Form.RecordSource = "客戶查詢"   '  Saved Query Object  or SQL string

    ' 加入篩選條件 strFilter 
 child_qry10.Form.Filter = strFilter
 child_qry10.Form.FilterOn = True
 child_qry10.Form.Requery
End Sub


---------------------------------------------------
' 篩選特定欄位的值 (字串或數值)
strFilter = "TEACHER = """ & "T001" & """"

' 篩選以今天到今天以後30天範圍
strFilter = strFilter & "StartDate between #" & Date & "# And #" & Date + 30 & "#"


'   篩選特定日期範圍
 strFilter = strFilter & "StartDate between #" & "2015/5/1" & "# And #" & "2015/5/31" & "#"

沒有留言 :

張貼留言