I have an Access-db, currently split in frontend Access 2013, backend 2013.
I need to upsize to SQL-server.
In this database the DAO-recordset is used a lot, not ADODB. In cases where data needs to be found the .findfirst method is used, which works properly when using the Access-backend.
For example:
dim rst as DAO.recordset
set rs= currentdb("select * from cities", dbOpenDynaset, dbSeeChanges)
rs.FindFirst "City = ""New York"""
if Not rs.NoMatch Then
debug.print rs!city
else
debug.print "nothing found"
End If
When using the Access-backend this works, also if the recordset is empty. When using the SQL-database through ODBC this code generates an error on the .findfirst method if the recordset does not have records.
So, it the recordset is empty, then .findfirst does not work with SQL-odbc tables
This is unexpected. I COULD fix it by checking if the rs.eof and rs.bof is true but this is basically the same as a nomatch and it would require me to rewrite a LOT of modules just to overcome this. Also in my situation no records is a viable option which should trigger the "nomatch" procedure (in this example the debug.print "nothing found")
I was under the assumption - based on a few other projects on SQL-server that I am working on - that declaring the recordset explicitly as DAO (and adding dbOpenDynaset, dbSeeChanges to the openrecordset) would suffice to make it work?
I can't find any info on .findfirst not working on empty recordsets? (it clearly works when using a access-backend and DAO-recordset)
I need to upsize to SQL-server.
In this database the DAO-recordset is used a lot, not ADODB. In cases where data needs to be found the .findfirst method is used, which works properly when using the Access-backend.
For example:
dim rst as DAO.recordset
set rs= currentdb("select * from cities", dbOpenDynaset, dbSeeChanges)
rs.FindFirst "City = ""New York"""
if Not rs.NoMatch Then
debug.print rs!city
else
debug.print "nothing found"
End If
When using the Access-backend this works, also if the recordset is empty. When using the SQL-database through ODBC this code generates an error on the .findfirst method if the recordset does not have records.
So, it the recordset is empty, then .findfirst does not work with SQL-odbc tables
This is unexpected. I COULD fix it by checking if the rs.eof and rs.bof is true but this is basically the same as a nomatch and it would require me to rewrite a LOT of modules just to overcome this. Also in my situation no records is a viable option which should trigger the "nomatch" procedure (in this example the debug.print "nothing found")
I was under the assumption - based on a few other projects on SQL-server that I am working on - that declaring the recordset explicitly as DAO (and adding dbOpenDynaset, dbSeeChanges to the openrecordset) would suffice to make it work?
I can't find any info on .findfirst not working on empty recordsets? (it clearly works when using a access-backend and DAO-recordset)
Last edited: