How do I add the visual basic AddAllToList() Function to a form: Idiot's guide please !

Posted on 2007-10-10
Last Modified: 2013-11-27
I would like to be able to use the Addalltolist function described here :

However when it comes to Visual Basic I know about as much as a particularly dumb muppet.

I've tried following the instructions that the microsoft article gives. I've opened a form, selected one of the comboboxes in which I would like to have an "All" option into and then clicked on "Code".

Visual Basic opens up and I've tried pasting all the code from microsoft's article at the bottom of the screen full of visual basic code that already exists (from macros I've written I assume).

When I do that and then press compile the following gets highlighted "Static DB As Database, RS As Recordset" and a message box states that User defined type not defined.

I've also tried right clicking and creating a Class Module where I pasted some stuff. That broke my database (fear not I backed it up).

Can anyone give me an idea of what I'm doing wrong and how I can make things work. I know its a bit of a challenge but I really need the functionality that the microsoft article suggests I could get. I've tried playing with union queries but that's not going so well either !

Question by:DanSeal100
    LVL 38

    Accepted Solution

    Static DB As Database, RS As Recordset
    Static db As DAO.Database, rs As DAO.RecordsetStatic db As DAO.Database, rs As DAO.Recordset

    LVL 4

    Assisted Solution

    You also need to add a reference to a DAO library. The default Access references include only ADO. To do this, open any code in the code editor. Then:
    1. Select Tools > References from the menu. You will see 4 or 5 library references already checked.
    2. Scroll down through the unchecked references. Look for "Microsoft DAO X.y Object Library, where X.y is a version number such as 3.5 or 3.6.
    3. Check the highest version number that you see.
    4. Click OK.
    5. Use Debug / Compile [projectname] to compile your code


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now