First problem is that I have to click the down arrow in the cbox to see the
first record. How do I change that? Second problem is populating each column.
That I can't figure out. Below is the function. As you can see the line that
isn't commented out will get the first column, the second gets the second
column of the record, but both are put in the first column of the combo box.
How do I populate the three columns with corresponding fields and will this
loop through and get all db records specified in the query.
As you can see I commented out some lines that i thought would work, but
don't. I recieve a 424 run-time error, "object required". Would this work if
I solve that problem?
Expand|Select|Wrap|Line Numbers
- Public Function AddToCombo()
- Dim dbs As Database, rst As Recordset, strSQL As String, strSQL1 As
- String
- 'now get the rest of the data from OrderInfo where ordernumber is same
- 'and set to variables
- strSQL = ""
- strSQL1 = ""
- Set dbs = CurrentDb
- strSQL1 = "SELECT * FROM OrderData where ordernum = "
- strSQL = strSQL1 & OrderNum
- Set rst = dbs.OpenRecordset(strSQL)
- With rst
- i = 0
- Do Until .EOF
- cmbOrders.AddItem .Fields(1).Value
- cmbOrders.AddItem .Fields(2).Value
- ' cmbOrders.AddItem (i)
- ' cmbOrders.Column(0, i) = .Fields("Quantity")
- ' cmbOrders.Column(1, i) = .Fields("Description")
- ' cmbOrders.Column(2, i) = .Fields("Price")
- .MoveNext
- i = i + 1
- Loop
- End With
- rst.Close
- End Function