Perhaps it is a combination of things. Here is some code from MS and the answer may be here. How are you looking at the recordset? You may only be seeing the first record it grabs:
Option Explicit
'Define Variables
Private Sub UserForm_Initialize()
Dim dbDatabase As Database
Dim rsNorthwind As Recordset
Dim i As Integer
Dim aResults()
' This code activates the Database connection. Change
' the path to reflect your database.
Set dbDatabase = OpenDatabase("C:\My Documents\NorthWind.mdb")
' This code opens the Customers table. Change the Table
' to reflect the desired table.
Set rsNorthwind = dbDatabase.OpenRecordset("Customers", dbOpenSnapshot)
i = 0
With rsNorthwind
' This code populates the combo box with the values
' in the CompanyName field.
Do Until .EOF
ComboBox1.AddItem (i)
ComboBox1.Column(0, i) = .Fields("CompanyName")
.MoveNext
i = i + 1
Loop
End With
End Sub
Notice that to populate a combo box, as here, you have to loop through the recordset to see all the values.
I also found some documentation that states with old DAO, at least, you need to Dim and Set this value, like this:
Dim dbOpenSnapshot
dbOpenSnapshot=4
I don't think that is the issue. I think you are only looking at the first record and not looping through. Try doing this:
Set rsDividends = dbs.OpenRecordset("SELECT * FROM tblDividends WHERE ASX_Code = ""NAB""", dbOpenSnapshot)
i = 0
rsDividends.MoveFirst
Do Until rsDividends.EOF
i = i + 1
rsDividends.MoveNext
Loop
MsgBox i
and see what the count is.
mmcdonal
|