Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Quebec City, Quebec, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dim As Field (2002)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dim As Field (2002)

    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.
    Charlotte

  3. #3
    Lounger
    Join Date
    Mar 2002
    Location
    Quebec City, Quebec, Canada
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Dim As Field (2002)

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Dim As Field (2002)

    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. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •