下面我的卖家组合框(cboSeller)的行数源,目前显示所有卖家多年。这项工作正常,但是这个列表变得太长而且不合适,所以我需要将它限制在当年的卖家。
SELECT tblSeller.SellerID, tblSeller.SellerName, tblSeller.sellerCurrent FROM tblSeller ORDER BY tblSeller.SellerName;
添加新促销时,我想将组合框中的值仅限制为当前活动的卖家。在tblSeller中,当前卖家在sellerCurrent字段中用“是”值表示。
当我将组合框的rowsource更改为查询时,卖家的条件设置为“yes”,cboSeller组合框工作并仅显示当前卖家。
但是,在查看具有上一年卖家的现有销售记录时,请勿在cboSeller字段中显示卖家。
所以看起来我需要做的是,在添加新的销售记录时,将cboSeller的rowsource更改为带有Yes条件的查询。查看所有销售记录时,需要删除标准并恢复为显示所有销售商。
我该怎么做?
非常感谢任何建议......干杯。
答案 0 :(得分:1)
使用 OnCurrent 事件重新查询组合框,如果您指定了不同的行源,则会发生这种情况。
Private Sub Form_Current
Const AllSellers As String = <your Select .. for all sellers.>
Const NewSellers As String = <your Select .. for current only sellers.>
Dim RowSource As String
If Me.NewRecord Then
RowSource = NewSellers
Else
RowSource = AllSellers
End If
If Me!cboSellers.RowSource <> RowSource Then
Me!cboSellers.RowSource = RowSource
End If
End Sub