|
- Dim Cnn As Object
- Dim Rst As Object
- Private Sub ComboBox1_Change()
- Research Me.ComboBox2, "select distinct 判定车系 from sheet1 where 判定品牌 = '" & Me.ComboBox1.Text & "'"
- End Sub
- Private Sub UserForm_Initialize()
- Set Cnn = CreateObject("adodb.connection")
- Set Rst = CreateObject("adodb.recordset")
- With Cnn
- .Provider = "microsoft.ace.oledb.12.0"
- .Open "Data Source=" & ThisWorkbook.Path & "\123.accdb" & ";Jet OLEDB:DataBase Password=tf751115;"
- End With
- Research Me.ComboBox1, "select distinct 判定品牌 from sheet1"
- End Sub
- Private Sub UserForm_Deactivate()
- Cnn.Close
- Set Cnn = Nothing
- Set Rst = Nothing
- End Sub
- Private Function Research(obj, sql)
- Rst.Open sql, Cnn, 3, 2
- obj.Clear
- For i = 0 To Rst.RecordCount - 1
- obj.AddItem Rst.Fields(0).Value
- Rst.movenext
- Next
- Rst.Close
- End Function
复制代码 |
|