|
6#
楼主 |
发表于 2008-12-29 14:00:00
|
只看该作者
这是我中午做的,可是不知道什么原因,老是引用错误,那个计数和合计是后加的,能正常使用,麻烦指点下,看看什么问题
Option Compare Database
Option Explicit
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 & "([面积] >= " & Me.面积开始 & ") AND "
End If
If Not IsNull(Me.面积截止) Then
strWhere = strWhere & "([面积] <= " & Me.面积截止 & ") AND "
End If
If Not IsNull(Me.发布时间开始) Then
strWhere = strWhere & "([发布时间] >= #" & Format(Me.发布时间开始, "yyyy-mm-dd") & "#) AND "
End If
If Not IsNull(Me.进书日期截止) Then
strWhere = strWhere & "([发布时间] <= #" & Format(Me.发布时间截止, "yyyy-mm-dd") & "#) AND "
End If
If Len(strWhere) > 0 Then
strWhere = Left(strWhere, Len(strWhere) - 5)
End If
Debug.Print strWhere
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
Private Sub cmd清除_Click()
On Error GoTo Err_cmd清除_Click
Dim ctl As Control
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox
If ctl.Locked = False Then ctl.Value = Null
Case acComboBox
ctl.Value = Null
End Select
Next
'取消子窗体的筛选
Me.全城区广告查询窗体.Form.Filter = ""
Me.全城区广告查询窗体.Form.FilterOn = False
Call CheckSubformCount
Exit_cmd清除_Click:
Exit Sub
Err_cmd清除_Click:
MsgBox Err.Description
Resume Exit_cmd清除_Click
End Sub
Private Sub CheckSubformCount()
If Me.存书查询子窗体.Form.Recordset.RecordCount > 0 Then
'子窗体的记录数>0
Me.计数.ControlSource = "=[全城区广告查询窗体].[Form].[txt计数]"
Me.面积.ControlSource = "=[全城区广告查询窗体].[Form].[txt面积合计]"
Else
'子窗体的记录数=0
Me.计数.ControlSource = "=0"
Me.合计.ControlSource = "=0"
End If
End Sub
Private Sub 城区_afterupdate()
Me.路段.RowSource = "select 路段,路段编号 from 城区路段表 where 城区='" & Me.城区 & "'"
End Sub
Private Sub 路段_AfterUpdate()
Me.全城区广告查询窗体.Form.Filter = "路段编号='" & Me.路段 & "'"
Me.全城区广告查询窗体.Form.FilterOn = True
End Sub |
|