VBA Combobox控件模糊查找+拼音查找怎么做?

PrivateSubWorksheet_SelectionChange(ByValTargetAsRange)OnErrorResumeNextDimstrNAsStri... Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Dim strN As String
Set cnn = CreateObject("adodb.connection")
cnn.Open "Provider=microsoft.jet.oledb.4.0;Data Source =Z:\KD\KDDATA\" & Sheet3.[D2] & "数据库.mdb"
sql = "Select distinct 客户名称 from 开单资料"
strN = "Select distinct 客户名称 from 开单资料"
If IsNull(strN) Then
MsgBox "数据库可能为空"
Else
arr = cnn.Execute(sql).GetRows

Sheet3.ComboBox1.List = WorksheetFunction.Transpose(arr)

If (Target.Column = 2 Or Target.Column = 3) And Target.Row = 2 Then
If IsDate(Target) Then
Calendar1.Value = Target
Else
Calendar1.Today
End If
Calendar1.Visible = -1
Calendar1.Top = ActiveCell.Top + ActiveCell.Height
Calendar1.Left = ActiveCell.Left
Else
Calendar1.Visible = 0
End If
End If
If Sheet3.Cells(2, 3) <> "" Or Sheet3.Cells(2, 3) <> "" Then
Sheet3.ComboBox1.Value = ""
End If

或加扣 360056670
展开
 我来答
20010309b
2013-07-17 · 超过14用户采纳过TA的回答
知道答主
回答量:211
采纳率:0%
帮助的人:124万
展开全部
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Dim strN As String
Set cnn = CreateObject("adodb.connection")
cnn.Open "Provider=microsoft.jet.oledb.4.0;Data Source =Z:\KD\KDDATA\" & Sheet3.[D2] & "数据库.mdb"
sql = "Select distinct 客户名称 from 开单资料"
strN = "Select distinct 客户名称 from 开单资料"
If IsNull(strN) Then
MsgBox "数据库可能为空"
Else
arr = cnn.Execute(sql).GetRows

Sheet3.ComboBox1.List = WorksheetFunction.Transpose(arr)

If (Target.Column = 2 Or Target.Column = 3) And Target.Row = 2 Then
If IsDate(Target) Then
Calendar1.Value = Target
Else
Calendar1.Today
End If
Calendar1.Visible = -1
Calendar1.Top = ActiveCell.Top + ActiveCell.Height
Calendar1.Left = ActiveCell.Left
Else
Calendar1.Visible = 0
End If
End If
If Sheet3.Cells(2, 3) <> "" Or Sheet3.Cells(2, 3) <> "" Then
Sheet3.ComboBox1.Value = ""
End If
你都很正确
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式