通过以下代码(插入组合框的更新后事件中),可以实现用组合框重复多选,也可以手工修改录入内容:
Private Sub Combo0_AfterUpdate()
Dim i As Integer, strList As String
With Combo0
For i = 1 To .ListCount
strList = IIf(Nz(strList) = "", "", strList & ";") & .ItemData(i)
Next
If Nz(.Text) <> "" Then
If InStr(1, .Tag, .Text) = 0 And InStr(1, strList, .Text) > 0 Then
.Value = IIf(Nz(.Tag) = "", "", .Tag & "、") & .Text
End If
.Tag = .Text
Else
.Tag = ""
End If
End With
End Sub作者: t小宝 时间: 2008-6-6 16:18
非常巧妙,学习了[:50]作者: Trynew 时间: 2008-6-6 16:19
经测试,可以省掉其中4行:
Private Sub Combo0_AfterUpdate()
Dim i As Integer, strList As String
With Combo0
For i = 1 To .ListCount
strList = IIf(Nz(strList) = "", "", strList & ";") & .ItemData(i)
Next
If InStr(1, .Tag, .Text) = 0 And InStr(1, strList, .Text) > 0 Then
.Value = IIf(Nz(.Tag) = "", "", .Tag & "、") & .Text
End If
.Tag = .Text
End With
End Sub作者: rjacky 时间: 2008-6-6 17:09
好东西[:50]作者: fswxs 时间: 2008-6-6 20:36
trynew站长,很久不见,终于又尝试新的了[:34]作者: 5988143 时间: 2008-6-6 21:36
精品不断![:50]作者: goto2008 时间: 2008-6-7 01:02
太有创意了,学习作者: tmtony 时间: 2008-6-7 01:44
不服不行!!作者: Trynew 时间: 2008-6-7 02:06
进一步,可以把此功能做成通用函数,在公共模块中建立函数:
Public Function MultComb()
Dim i As Integer, strList As String
With Screen.ActiveControl
For i = 1 To .ListCount
strList = IIf(Nz(strList) = "", "", strList & ";") & .ItemData(i)
Next
If InStr(1, .Tag, .Text) = 0 And InStr(1, strList, .Text) > 0 Then
.Value = IIf(Nz(.Tag) = "", "", .Tag & "、") & .Text
End If
.Tag = .Text
End With
End Function