Tag Archives: listview

Access Tips Visual Basic For Applications (VBA)

Making Intellisense work in Access VBA

I’ve just had a little problem where I was programming with a ListView control in Access and, for some reason my Intellisense broke in VBA so I couldn’t get access to the handy dropdown of methods and properties that comes in so useful as you’re developing.  I tried changing settings in VBA to no avail, but eventually found a solution.

If you’re suffering similar problems try the following steps:-

Create a module-level variable with type as ListView, for example:-

Dim MyListView as ListView

Then, in the Form_Load event, add code to reference the new variable to your listview control, like this:-

Set MyListView = [your listview name here].Object

And from this point refer to your listview control using the variable name rather than the name of the actual control. All your intellisense will come back perfectly. I know it seems a long-winded way around fixing things but hey, it works!  I’ve not tried it with everything, but I would assume that the same method will work for any controls for whom Intellisense seems broken.

Tips Visual Basic For Applications (VBA)

VBA Quick Tip: Looping through the items in a ListView control

If you’re wanting to loop through the items in a ListView control (for example, to do something for each item that exists in the control) this is how you can do it.  It really bugged me today as I couldn’t remember.

For yourVariable = 1 to yourListView.ListItems.Count