|
一个例子
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click
'查询语句
Me.Refresh
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 Len(strWhere) > 0 Then
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
Me.frmChaxun1.Form.FilterOn = True
Me.frmChaxun1.Form.Filter = strWhere
'为了记录计数正确,使用这个语句
Me.frmChaxun1.Form.Recordset.MoveLast
'显示查询结果计数
If Me.查询记录计数 = 0 Then
MsgBox "没有查询到任何记录!", vbExclamation, "注意!"
Else
MsgBox "当前查询到" & Me.查询记录计数 & "条记录!", vbInformation, "注意!"
End If
Exit_Command13_Click:
Exit Sub
Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click
End Sub |
|