![]() |
|
#3
|
|||
|
|||
|
Quote:
Quote:
Quote:
I'm ashamed to admit that I went through all three of your replies in exhaustive detail but I still don't seem to be getting it. For now I am just trying to use Excel as the data source. I tried to create a simple form with one list box control and a named range in excel with four values in the column. ![]() ![]() Code:
Sub InitializeDocument()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
'Set db = OpenDatabase("C:\Temp\ItemSheet.xlsx", False, False, "Excel 12.0")
Set db = OpenDatabase("C:\Temp\ItemSheet.xlsx", False, False, "Excel 12.0; IMEX=1;")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM ItemRange")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ListBox1.ColumnCount = rs.Fields.Count
' Load the ListBox with the retrieved records
ListBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Sorry for the never ending newbie questions.
|
|
|