D
DGjr.
How do I take the following code and build a repeating loop to build an
identical list in 13 different ComboBoxes (i.e. ComboBox1 thru ComboBox13)?
Private Sub Document_Open()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Filename.xls", False, False, "Excel 8.0")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM `SftwrProd`")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ComboBox1.ColumnCount = rs.Fields.Count
' Load the ComboBox with the retrieved records
ComboBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Thanks.... DGjr.
identical list in 13 different ComboBoxes (i.e. ComboBox1 thru ComboBox13)?
Private Sub Document_Open()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
' Open the database
Set db = OpenDatabase("C:\Filename.xls", False, False, "Excel 8.0")
' Retrieve the recordset
Set rs = db.OpenRecordset("SELECT * FROM `SftwrProd`")
' Determine the number of retrieved records
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
' Set the number of Columns = number of Fields in recordset
ComboBox1.ColumnCount = rs.Fields.Count
' Load the ComboBox with the retrieved records
ComboBox1.Column = rs.GetRows(NoOfRecords)
' Cleanup
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Thanks.... DGjr.