• Dim As Field (2002)

    Author
    Topic
    #393040

    I wrote quite a large program a few years ago with Access 97, using a lot of references to fields such as :

    Dim dbPf As Database
    Dim rcdInvDet As Recordset
    Dim fldClo As Field

    Set dbPf = DBEngine.Workspaces(0).Databases(0)
    Set rcdInvDet = dbPf.OpenRecordset(“InvoiceDetails”)
    Set fldClo = rcdInvDet![Closed]

    But MSAccess 2002 doesn’t seem to recognize the last statement anymore, provoking an error at that last line.

    Has something changed in 2002 ? I would like to get it working again, for a new user. Any help would be appreciated.

    Viewing 1 reply thread
    Author
    Replies
    • #709938

      What has changed from 97 is that Access 2000 and Access 2002 use ADO as the default object model instead of DAO. Check your references and make sure you have the DAO 3.6 object model checked. If you don’t use ADO, you can safely remove the ADO reference, and I recommend that you do so.

      The alternative is to carefully go through your code and make sure each object like Database, Recordset, Field, Parameter, QueryDef, TableDef, Index, etc., is define as a DAO.Database, etc. This tells the Access engine which object model to use when evaluating the syntax of the code. Since database, querydef, and tabledef objects don’t exist in ADO, and recordsets, fields, parameters, indexes, etc., have different methods and properties in ADO, you save yourself and Access a lot of confusion by making it perfectly clear which library you’re using, either by specifying it in each declaration or by removing the reference you don’t use.

      • #735569

        I just realized that I did not thank you Charlotte for your help.
        I tried the first recommendation, but found that the DAO 3.6 object model was already checked.
        So I went to the second suggestion, and, with the help of Search and find, (or was it by compiling), I located all the instances that were giving problems, and added DAO before the reference.
        It worked !

        Thanks a lot Charlotte.

        • #735573

          I’m glad you got it working. Just make it a habit in the future on all your declarations, and you’ll save yourself trouble going forward as well. smile

        • #735574

          I’m glad you got it working. Just make it a habit in the future on all your declarations, and you’ll save yourself trouble going forward as well. smile

      • #735570

        I just realized that I did not thank you Charlotte for your help.
        I tried the first recommendation, but found that the DAO 3.6 object model was already checked.
        So I went to the second suggestion, and, with the help of Search and find, (or was it by compiling), I located all the instances that were giving problems, and added DAO before the reference.
        It worked !

        Thanks a lot Charlotte.

    • #709939

      What has changed from 97 is that Access 2000 and Access 2002 use ADO as the default object model instead of DAO. Check your references and make sure you have the DAO 3.6 object model checked. If you don’t use ADO, you can safely remove the ADO reference, and I recommend that you do so.

      The alternative is to carefully go through your code and make sure each object like Database, Recordset, Field, Parameter, QueryDef, TableDef, Index, etc., is define as a DAO.Database, etc. This tells the Access engine which object model to use when evaluating the syntax of the code. Since database, querydef, and tabledef objects don’t exist in ADO, and recordsets, fields, parameters, indexes, etc., have different methods and properties in ADO, you save yourself and Access a lot of confusion by making it perfectly clear which library you’re using, either by specifying it in each declaration or by removing the reference you don’t use.

    Viewing 1 reply thread
    Reply To: Dim As Field (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: