Results 1 to 5 of 5
  1. #1
    PinkLady50 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    171

    Compile Error User Defined type not defined Dim db as DAO.database

    I have an existing database that is working fine. I took of copy of the database and made some enhancements with the addition of some tbls, queries and forms. This weekend I moved all my new objects (tbls, queries and forms) into the existing database. Everything came over fine. When I tested , all the tbls, queries and forms all work in the previous portion of the database and just about all of the new stuff I add is working with one exception.




    I have one group of coding that is getting an error and I am not sure what to do. When the code runs from the form I get the following error.
    Compile Error - User Defined type not defined and the error is on the Dim db as DAO.database. I read up on this last night and it says to check something on the Tools/Reference menu. When I tried to do that the Reference was greyed-out.

    Not sure what is causing it. Nothing has changed from one version of the database to the other except the addition of some objects. All my other code runs fine.

    Any suggestions!!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    it is probably greyed out because your code is still running - even if stopped temporarily to enable you to handle the error.

    To declare DAO.Database, you probably need the Microsoft Office 14.0 Access Database Engine Object Library installed in references

  3. #3
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    DONT dim it as DAO database, dim it variant for late binding:

    dim db
    set db = currentdb

    or load in the DAO reference, which there is no point in using DAO since you are already in an active database. No code needed.

  4. #4
    PinkLady50 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    171
    Can I do the same with Dim rs As DAO.Recordset.

  5. #5
    PinkLady50 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2017
    Posts
    171
    Thanks! This worked perfectly!!! Much appreciated!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DAO ERROR - User Defined type not defined
    By adamtate94 in forum Programming
    Replies: 2
    Last Post: 09-08-2016, 05:42 AM
  2. Replies: 3
    Last Post: 11-12-2013, 04:13 PM
  3. Replies: 1
    Last Post: 12-14-2012, 12:32 AM
  4. Replies: 4
    Last Post: 06-08-2012, 09:08 AM
  5. Error: "User-defined type not defined"
    By mastromb in forum Programming
    Replies: 10
    Last Post: 01-08-2010, 02:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums