Alright, here’s an odd one from an MS Access database I’m running.
I have a SQL query:
SELECT *
FROM [Service Schedule]
WHERE ID=2
AND Volume <= 3000
AND Term='Monthly'
AND special = 'Regular'
ORDER BY volume
When I put that into the SQL view of the query builder, I get 2 records, one with a volume of 0 and one with a volume of 3000.
When I use this code:
sSQL = "SELECT * FROM [Service Schedule] WHERE ID=2 AND Volume <= 3000 AND Term='Monthly' and special = 'Regular' ORDER BY volume"
Set rsServiceSched = CurrentDb.OpenRecordset(sSQL, dbOpenDynaset, dbSeeChanges)
** To see what I’m getting from the query in the code, I’m using Debug.Print to output the recordcount and the volume.
I only get 1 record, the one with the volume of 0.
Here’s where it gets really strange…
When I change Volume <= 3000 to Volume < 3000 I get one record (volume = 0)
When I change Volume <= 3000 to Volume = 3000 I get one record (volume = 3000)
Anyone spot anything blatantly wrong with what I’m doing?
It sounds like you are expecting to ‘see’ all of the records, but I think you are just retrieving the first record. I say this because you are seeing what would be the first record with each case. You will probably need to move to the next record in your recordset in order to see the next one.