• ** There has been a recent site upgrade. Please clear your browser cache to avoid issues. **
  • New forum feature - post voting and best solution

    Check out this thread for the details: https://www.access-programmers.co.uk/forums/threads/new-forum-feature-post-voting-and-best-answer.314134/

    This new feature looks great to me! :)

  • We now have 3 forum themes

    Go for the default (light) theme, Shades of Grey or Shades of Blue. I just added the Blue one.

    The thread about it is here: https://www.access-programmers.co.uk/forums/threads/new-forum-theme-shades-of-blue.314136/

Developing Custom Classes to Simulate User Controls (1 Viewer)

Status
Not open for further replies.

MajP

You've got your good things, and you've got mine.
Local time
Today, 10:15
Joined
May 21, 2018
Messages
3,497
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

  • MajP FAYT V10.accdb
    1.1 MB · Views: 58
  • ListBoxSorter V1.accdb
    1.3 MB · Views: 52
  • MultiSelectListBoxControl V2.accdb
    1.4 MB · Views: 47
Last edited:

isladogs

CID VIP
Local time
Today, 14:15
Joined
Jan 14, 2017
Messages
13,955
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

Top Bottom