Reputation: 65
In Access VBA is there a difference between:
Dim rs As Recordset
Dim rs As DAO.Recordset
Upvotes: 4
Views: 2734
Reputation: 27634
It depends on the references you have set in the VBA project.
If you haven't changed anything, then there are only DAO recordsets. If there is no chance that ADO will ever be used in that project,
Dim rs As Recordset
is enough to specify a DAO.Recordset
. But for clarity it is still recommended to use
Dim rs As DAO.Recordset
But if you have both the Access database engine, and ActiveX Data Objects libraries in your references (see on the right),
then you must use the qualifier to specify what recordset you want (see left). If you just use Dim rs As Recordset
here, it will depend on the order of the references, which one is used.
Upvotes: 3
Reputation: 55816
The difference is, that also ADO has a Recordset. Using DAO makes it clear what the object is.
Upvotes: 1