如果可以使用
.Value
属性或
.Column
集合而不是
.Text
:
Private Sub RequerylstResume()
Dim SQL As String
SQL = "SELECT qryResume.ID, qryResume.Company, qryResume.Job, qryResume.LastUpdated " _
& "FROM qryResume " _
& "WHERE 1=1 "
If cboJob.Value & "" <> "" Then
SQL = SQL & " AND qryResume.Job = '" & cboJob.Value & "'"
End If
If cboCompany.Value & "" <> "" Then
SQL = SQL & " AND qryResume.Company = '" & cboCompany.Value & "'"
End If
If Me.TextKeyWords.Value & "" <> "" Then
SQL = SQL & " AND (Company LIKE '*" & Me.txtKeywords & "*' " _
& " OR Job LIKE '*" & Me.txtKeywords.Value & "*') "
End If
SQL = SQL & " ORDER BY qryResume.Company"
Me.lstResume.RowSource = SQL
Me.lstResume.Requery
End Sub
然后,无论何时您想要执行搜索,只要调用
RequerylstResume
.
您可以这样称呼sub:
Private Sub cboJob_AfterUpdate()
RequerylstResume
End Sub
并将要调用的sub放在同一模块中,在任何其他sub之外