• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

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

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 !

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

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now