|
因你的附件上没有后台数据库,所以没有办法给你调试,问题是出在筛选条件上,你是借用了刘小军多条件查询一段代码,可惜你没有真正理解,你的条件多了5个字符串,要去掉.
修改一下:
Private Sub cmd查询_Click()
On Error GoTo Err_cmd查询_Click
Dim strWhere As String
strWhere = ""
If Not IsNull(Me.name) Then
strWhere = strWhere & "([企业名称] like '*" & Me.name & "*') AND "
End If
If Not IsNull(Me.leibie) Then
strWhere = strWhere & "([项目类别] like '*" & Me.leibie & "*') AND "
End If
If Not IsNull(Me.adress) Then
strWhere = strWhere & "([项目地点] like '*" & Me.adress & "*') AND "
End If
If Not IsNull(Me.from) Then
strWhere = strWhere & "([来源渠道] like '*" & Me.from & "*') AND "
End If
If Not IsNull(Me.startmoney) Then
strWhere = strWhere & "([融资金额] >= " & Me.startmoney & ") AND "
End If
If Not IsNull(Me.endmoney) Then
strWhere = strWhere & "([融资金额] <= " & Me.endmoney & ") AND "
End If
If Not IsNull(Me.starttime) Then
strWhere = strWhere & "([申请时间] >= #" & Format(Me.starttime, "yyyy-mm-dd") & "#) AND "
End If
If Not IsNull(Me.endtime) Then
strWhere = strWhere & "([申请时间] <= #" & Format(Me.endtime, "yyyy-mm-dd") & "#) AND "
End If
'Debug.Print strWhere
If Len(strWhere) > 0 Then
'有输入条件
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
Me.[申贷项目_子窗体].Form.Filter = strWhere
Me.[申贷项目_子窗体].Form.FilterOn = True
'Call CheckSubformCount '这是调用一个自编子程序,专门用来检查子窗体上的记录数,如果没有请去掉.
Exit_cmd查询_Click
Exit Sub
Err_cmd查询_Click:
MsgBox Err.Description
Resume Exit_cmd查询_Click
End Sub |
|