Developing Custom Classes to Simulate User Controls

Status
Not open for further replies.

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:26
Joined
May 21, 2018
Messages
8,928
Access OOP examples wanted

Some people have shown interest in custom classes lately, and was asked for some more examples. I use custom classes extensively, but the most important use in Access is the ability to extend control functionality and basically simulate building a user control. Once you build it once you can encapsulate a tremendous amount of functionality and reuse it without having to rewrite code. Normally it requires one or two lines to initialize the class. Here are a few examples

1) Find/Filter as you Type (FAYT). There are several classes here that turn a combobox, form, or listbox into a find as you type. In other words as you type it filters the list. There are several properties to configure how it filters

2) Listbox sorter. This captures the events of several command buttons and the listbox to allow the user to move records up and down in the list. It has lots of features to return the sorted list or row / column values.

3) From To List. Allows you to take any two listboxes and a group of command buttons and move items from one list to the other list.

4)MultiSelect Listbox control. This takes a multiselect listbox and returns a filter string based on the bound column

I apologize the MultiSelectListBoxQuery was the incorrect file the file I wanted had a similar name. I have updated the correct MultiSelectListBoxControl V2 I

The From To List example is a real important example, and it needs a lot better explanation. As I have discussed a form is a class and follows the same use as a custom class. In this example I use the form FromToList in multiple forms as a subform acting as a control. I have put in the subform multiple custom events, custom properties, and methods. It is able to act as a control on multiple forms because the properties are passed into it. If you look how this subform is instantiated and the subform's class this will look almost identical to using a custom class. If you can wrap your head around this useage you will have a real good understanding of OOP in Access.

I originally made this as a custom class where you could provide the listboxes and command buttons. So I will go back and update this module with both versions. A pure custom class and a customized form class. That would highlight even more concepts.
 

Attachments

Last edited:
At several users' request & with MajP's agreement, I copied this from post #60 of a lengthy thread Access OOP examples wanted.
This post is to ensure the thread is flagged in New Posts so that others are aware of its existence
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom