Excel VBA Recordset问题

时间:2017-11-20 11:35:37

标签: excel vba excel-vba

我有以下代码,我有一个问题: 1.我用记录集中的DEN字段填充列表框,我还有一个名为tx1的文本框。当我在列表中上下移动时,我想用textList.text填充该列表中记录的相应值 例如:

DEN: Mary
CODE:M1

所以,我想在文本框中检索“M1”。我怎么能这样做?

谢谢!

Apppath
Dim j As Integer
Dim cna As New ADODB.Connection
Dim rsee As New ADODB.Recordset
cna.Open "ODBC;DSN=Firebird;Driver=Firebird/InterBase(r) driver;Dbname=" & yserver & ":" & ycale & ydb & ";CHARSET=NONE;UID=SYSDBA; PWD=blank;Client=" & ThisWorkbook.Path & "\fbclient.dll"

cna.BeginTrans
rsee.Open "SELECT DEN, CODE from PROD order by DEN asc", cna, adOpenKeyset, adLockPessimistic
cna.CommitTrans

If rsee.RecordCount > 0 Then
Me.lstProducts.ColumnCount = rsee.Fields.Count
j = 0
    rsee.MoveFirst
    Do While Not rsee.EOF
    Me.lstProdus.AddItem
    Me.lstProdus.List(j, 0) = rsee.Fields("DEN")
rsee.MoveNext
j = j + 1
Loop
End If

0 个答案:

没有答案