Re: Scan with Object or DAO.Recordset



The rule of thumb is to use the most specific data type you can.
Recordset is much more specific than Object.
(Variant is even broader yet.)

The only reason the Wizard usings Object is because Microsoft tried to introduce ADO recordsets into Access 2000, where previous versions had use DAO recordsets. So Object was the narrowest type they could use (since the Recordset object from the ADO library and the DAO library require disambiguating.) But when you write code, you know the library you are using, so:
Dim rst AS DAO.Recordset
is much better code.

One reason it's better is that Access is able to verify your code uses the correct methods and properties of that specific type. Using Object it can't verify the compilation. It can't offer all the right things in the Intellisense lists as you type the code either.

In summary, use the most specfic data type you can, and the narrowest scope you can.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<johnie@xxxxxxxxxx> wrote in message news:fkrsq0$288l$1@xxxxxxxxxxxxxxxxxxxxxx
To scan through a table and edit values I can use OpenRecordset with:
1. Dim rst As Object etc., or
2. Dim rst As DAO.Recordset etc.
Is there a performance difference between the two or are there reasons why I should be using one in stead of the other?

Thanks,
John

.



Relevant Pages

  • Re: Type mismatch
    ... > select the lowest date field in a specific recordset, ... >> The third argument of the DateAdd function must be a date data type. ... the SQL statement that you have posted will not work as you intend. ...
    (microsoft.public.access.formscoding)
  • Re: Null
    ... In my vb code I return a recordset from a sql database. ... > string and some are integers. ... > My client now wants to import that text file into their own SQL database. ... attempt to assign a Null value to it (DON'T change the variable's data type ...
    (microsoft.public.vb.syntax)
  • Re: Mismatched Data Type in an Expression
    ... (No private e-mails, please) ... > message on the SQL statement that says the data type is ... > Private Sub Requested_Docs_Received_Click ... > Dim M As Recordset, D As Database, C As Recordset ...
    (microsoft.public.access.modulesdaovba)
  • Re: DoCmd.RunSQL
    ... So I used recordset as a data type and kept everything else the same. ... > Dim MasterP As Integer ... > Exit Sub ...
    (microsoft.public.access.modulesdaovba)
  • Where clause in SQL statement problem
    ... I have an Access 97 database were I am opening a recordset in a module ... For some reason when the code executes I am ... getting an error message stating missing operator and I am not sure why. ... Dim rst as recordset ...
    (microsoft.public.access.formscoding)