支持文件:
表《销售表》
查询〈销售查询〉
窗体〈销售查询窗体〉
报表〈销售报表〉
步骤:
〈销售表〉生成〈销售查询〉,查询条件:like [forms]![销售查询窗体]![材质] & "*"
《销售查询》生成《销售查询窗体》数据源删掉,子窗体控件做出销售子窗体查询
注:《销售查询窗体》易犯错误:1.组合框,文本框--属性(事件)--更新后--事件过程---me.refresh
2.属性(数据)---数据源如果是两列--绑定列:2//格式--列数:2
代码如下:
Private Sub Command17_Click()
Dim strsql As String
strsql = "select * from 销售表 where 1=1"
If IsNull(Me.材质) = False Then
Me.材质.SetFocus
strsql = strsql & " and 材质 like '*" & Me.材质.Text & "*'"
End If
If IsNull(Me.规格) = False Then
Me.规格.SetFocus
strsql = strsql & " and 规格 like '*" & Me.规格.Text & "*'"
End If
If IsNull(Me.色号) = False Then
Me.色号.SetFocus
strsql = strsql & " and 色号 like '*" & Me.色号.Text & "*'"
End If
If IsNull(Me.销售日期) = False Then
Me.销售日期.SetFocus
strsql = strsql & " and 销售日期 like '*" & Me.销售日期.Text & "*'"
End If
If IsNull(Me.月份) = False Then
Me.月份.SetFocus
strsql = strsql & " and 月份 like '*" & Me.月份.Text & "*'"
End If
If IsNull(Me.客户编号) = False Then
Me.客户编号.SetFocus
strsql = strsql & " and 客户编号 like '*" & Me.客户编号.Text & "*'"
End If
Me.销售表子窗体.Form.RecordSource = strsql
Me.销售表子窗体.Form.Refresh
Me.Refresh
End Sub
Private Sub Command18_Click()
Me.材质 = Null
Me.规格 = Null
Me.色号 = Null
Me.销售日期 = Null
Me.月份 = Null
Me.客户编号 = Null
Me.销售表子窗体.Form.RecordSource = "select * from 销售表 where 1=1"
End Sub
Private Sub 材质_AfterUpdate()
Me.Refresh
End Sub
Private Sub 规格_AfterUpdate()
Me.Refresh
End Sub
Private Sub 客户编号_AfterUpdate()
Me.Refresh
End Sub
Private Sub 色号_AfterUpdate()
Me.Refresh
End Sub
Private Sub 销售日期_AfterUpdate()
Me.Refresh
End Sub
Private Sub 月份_AfterUpdate()
Me.Refresh
End Sub
按自己理解意思,写的不太详细,如有不明白请提问!