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 展开
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 展开
1个回答
展开全部
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
你都很正确
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
你都很正确
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询