Private Sub cmd查询_Click()
On Error GoTo Err_cmd查询_Click
Dim strWhere As String
strWhere = ""
If Not IsNull(Me.地区) Then
strWhere = strWhere & "[地区] like '" & "*" & Me.地区 & "*' And"
End If
If Not IsNull(Me.公司名称) Then
strWhere = strWhere & "[公司名称] like '" & "*" & Me.公司名称 & "*' And"
End If
If Not IsNull(Me.公司地址) Then
strWhere = strWhere & "[公司地址] like '" & "*" & Me.公司地址 & "*' And"
End If
If Not IsNull(Me.联系人) Then
strWhere = strWhere & "[联系人] like '" & "*" & Me.联系人 & "*' And"
End If
If Not IsNull(Me.联系方式) Then
strWhere = strWhere & "[联系方式] like '" & "*" & Me.联系方式 & "*' And"
End If
If Not IsNull(Me.机型) Then
strWhere = strWhere & "[机型] like '" & "*" & Me.机型 & "*' And "
End If
If Not IsNull(Me.出厂机型) Then
strWhere = strWhere & "[出厂机型] like '" & "*" & Me.出厂机型 & "*' and"
End If
strWhere = Left(strWhere, Len(strWhere) - 4)
Debug.Print strWhere
'让子窗体应用窗体查询
Me.资料查询子窗体.Form.Filter = strWhere
Me.资料查询子窗体.Form.FilterOn = True
Exit_cmd查询_Click:
Exit Sub
Err_cmd查询_Click:
MsgBox Err.Description
Resume Exit_cmd查询_Click
End Sub
试试看?
[此贴子已经被作者于2005-12-7 17:14:51编辑过]
|