Office中国论坛/Access中国论坛

标题: 升迁后就不能使用的一段代码,谢谢!急! [打印本页]

作者: walker-dong    时间: 2006-6-13 01:05
标题: 升迁后就不能使用的一段代码,谢谢!急!
Private Sub 查询_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.备用合同号 & "*') ADN "
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 & "([合同金额] >= " & Me.金额开始 & ") AND "
End If
'合同金额判断
If Not IsNull(Me.金额截止) Then
'有输入
strwhere = strwhere & "([合同金额]<= " & Me.金额截止 & ") AND "
End If



'如果输入了条件,那么strWhere的最后肯定有" AND ",这是我们不需要的,
'要用LEFT函数截掉这5个字符。
If Len(strwhere) > 0 Then
     '有输入条件
     strwhere = Left(strwhere, Len(strwhere) - 5)
End If

'这是本段代码的关键***********************

Me.合同信息子窗体.Form.Filter = strwhere
Me.合同信息子窗体.Form.FilterOn = True

'*****************************************

End Sub
作者: zhengjialon    时间: 2006-6-13 01:43
*号改成%试试
作者: walker-dong    时间: 2006-6-13 16:31
标题: 谢谢,问题已解决!
谢谢,问题已解决!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3