Take for example this code:
sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)
This statement can return more than one value. How can I access those values?
Take for example this code:
sSQL = "select CtyMarket from Market where Country = '" & Country.Value & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)
This statement can return more than one value. How can I access those values?
well, in order to get all the values you could browse both fields and records in your recordset. It could look like that:
Other ways to get your data would be to use the getrows and\or getstring metyhods of the recordset object, but I do not remember if these are available with DAO recordsets. You could also set a filter for a specific value on a specific field, etc
I use this function to not care about NULL values when reading recordsets:
Never trust the exact amount of
rec.recordcount
butrec.RecordCount>0
is safe. That's why you should never use a for loop when using a recordset. If you'd like to know the recordcount anyway what you have to do first isrec.movelast
and thenrec.movefirst
There are two different ways that I know of:
or