如何直接从Access窗体加载数据到Excel用户窗体列表框?

我想从Access加载一些数据到Excel的用户窗体列表框。 我现在正在做的是创buildADODB.Connection连接访问并创buildADODB.Recordset来存储数据,首先。 其次,我使用Range("xx").CopyFromRecordset将数据复制到Excel工作表。 第三,excel的名称范围为“ ResultSet ”。 第四,使用Me.ListName.RowSource="ResultSet"将数据从Excel工作表复制到ListBox。

正如你所看到的,我用四个步骤来完成这项工作。 有没有办法跳过第2步和第3步,直接从Access复制数据到ListBox?

谢谢

我find一篇文章。 以下是代码,这是链接 。

  With rs .MoveLast NoOfRecords = .RecordCount .MoveFirst End With 'Set the number of ListBox columns = number of fields in the recordset ListBox1.ColumnCount = rs.Fields.Count 'Load the listbox with the retrieved records ListBox1.Column = rs.GetRows(NoOfRecords) 

谢谢

对于单列列表框

尝试使用循环手动编辑列表:

 Me.ListName.Clear 'First clear existing list With Me.ListName While rs.EOF = False .AddItem rs.Fields(0).Value rs.MoveNext Wend End With 

用2-4步交换代码。