Office中国论坛/Access中国论坛

标题: "[Access小品】组合框自筛选示例,只有一条记录,不让自动填写 [打印本页]

作者: 13601812106_01    时间: 2010-11-19 12:48
标题: "[Access小品】组合框自筛选示例,只有一条记录,不让自动填写
【Access小品】就地正法---组合框自筛选示例
http://www.office-cn.net/forum-viewthread-tid-93509-fromuid-145480.html

请问
todaynew 老师,
怎么样才能让只有一条记录也能出现下拉的选项,而不是直接自动填写上去?

作者: todaynew    时间: 2010-11-19 16:20
本帖最后由 todaynew 于 2010-11-19 16:29 编辑

Private Sub 产品编号_NotInList(NewData As String, Response As Integer)
Dim ssql As String
Dim WH As String
Response = acDataErrContinue
ssql = "SELECT cpk.产品编号, '名称:' & [产品名称及规格] & ' 颜色:' & [颜色] & ' 单位:' & [单位] AS 品名 FROM cpk"
WH = " Where instr([产品名称及规格] & [颜色] & [单位],'" & NewData & "')>0"
Me.产品编号.RowSource = ssql & WH
If Me.产品编号.ListCount = 1 Then
    Me.产品编号.Value = Me.产品编号.Column(0, 0)
    ssql = "SELECT cpk.产品编号, '名称:' & [产品名称及规格] & ' 颜色:' & [颜色] & ' 单位:' & [单位] AS 品名 FROM cpk"
    Me.产品编号.RowSource = ssql
    Me.进货数量.SetFocus
Else
    Me.产品编号.Dropdown
End If
End Sub

修改为:
Private Sub 产品编号_NotInList(NewData As String, Response As Integer)
Dim ssql As String
Dim WH As String
Response = acDataErrContinue
ssql = "SELECT cpk.产品编号, '名称:' & [产品名称及规格] & ' 颜色:' & [颜色] & ' 单位:' & [单位] AS 品名 FROM cpk"
WH = " Where instr([产品名称及规格] & [颜色] & [单位],'" & NewData & "')>0"
Me.产品编号.RowSource = ssql & WH
Me.产品编号.Dropdown
End Sub



作者: 13601812106_01    时间: 2010-11-19 16:35
十分成功,真不知道怎么感谢你





欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3