Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    User-defined error (Excel VBA 2003)

    Hi,

    Im putting together a macro that interrogates an access database and imports data onto a worksheet. However when I compile I get an error stating "User-defined type not defined" and highlights the line "Dim dbs As database" - When I wrote this line the word database didnt appear in the auto list that usually appears when defining variables.

    Does anyone know why it doesnt seem to like the variable "database"??

    Ive switched on the option, DAO 3.6 Object Library.

    Any pointers will be appreciated.

    Many Thanks.
    Lee

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: User-defined error (Excel VBA 2003)

    You write "Ive switched on the option, DAO 3.6 Object Library." Do you mean that you've selected Tools | References... and ticked the check box for Microsoft DAO 3.6 Object Library? If so, VBA should recognize the keyword Database.
    To avoid ambiguity, change the declaration to

    Dim dbs As DAO.Database

    When you type the period (point, dot) after DAO, Database should be in the popup list.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: User-defined error (Excel VBA 2003)

    Hi Hans,

    Yes, I switched the option on via tools, references, etc...

    As you said, I defined the declaration more explicitly as DAO.Database and it seems to work fine now.

    Many thanks for your help.

    Regards.
    Lee

Posting Permissions

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