A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I found another way of doing it if anyone is interested, this way even if 1 record is returned it will be displayed correctly in the listbox
Private Sub searchDB(strSQL As String)
Dim objConn As Object
Dim objRecSet As Object
Dim i As Integer
'get data from Access database
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & wbCashRegister.Path & "\ccPOSDB.accdb"
Set objRecSet = objConn.Execute(strSQL & "ORDER BY ProductName ASC")
Me.lbxProductList.Clear
With Me.lbxProductList
While objRecSet.EOF = False
.AddItem
.List(i, 0) = objRecSet.Fields(0).Value
.List(i, 1) = objRecSet.Fields(1).Value
.List(i, 2) = Format(objRecSet.Fields(2).Value, "#,##0.00")
objRecSet.MoveNext
i = i + 1
Wend
End With
objRecSet.Close
Set objRecSet = Nothing
objConn.Close
Set objConn = Nothing