> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Using Class Modules in the Real World with Anders Ebro
- URL: https://nolongerset.com/aug-class-modules/
- Published: 2025-06-28T01:56:50.000Z
- Updated: 2026-05-08T12:46:08.000Z
- Description: Event-Driven Architecture and Custom Classes: Advanced Access Development Patterns (an Access User Group talk with Anders Ebro)
- Author: Mike Wolfe
- Tags: AUG Video Recap, Class Modules, #Import 2026-05-20 02:59

Ever wondered why your calendar code requires 40 identical event procedures and feels impossible to maintain?

Anders Ebro, a principal consultant and former Microsoft MVP from Denmark, delivered an engaging presentation to Access Europe demonstrating how class modules can transform repetitive, hard-to-maintain code into elegant, reusable solutions. Using a practical calendar implementation as his example, Anders showed how to move beyond the procedural programming that Access developers typically rely on and embrace the power of object-oriented design. His live coding demonstration illustrated both the "wrong way" (copy-pasted code across dozens of controls) and the "classy way" (using custom classes with events).

Whether you're tired of maintaining duplicate code or ready to explore more sophisticated programming patterns, this presentation offers a clear roadmap for incorporating classes into your Access development toolkit.

## Why Access Developers Resist Classes

### Familiar Alternatives

- Forms already act like classes with properties and methods
- Recordsets handle data interaction effectively
- Bound forms eliminate much complex coding
- Existing tools work well for most scenarios

### When to Consider Classes

- Notice patterns in your code
- Find yourself copy-pasting similar procedures
- Need better separation of concerns
- Want more maintainable solutions

## The Calendar Challenge

### The Problem: Procedural Approach

- 40+ text boxes each requiring click events
- Copy-pasted code with minor variations
- Mouse-over highlighting duplicated across controls
- Testing requires checking every single button
- Changes require 40+ code modifications

### The Class Solution Benefits

- Single place to define behavior
- One location for testing and debugging
- Easy maintenance and updates
- Cleaner, more professional code structure

## Building the DateDisplay Class

### Core Components

- **Variables**: Parent form reference, date value, recordset, text box
- **Initialize method**: Sets up the class with required parameters
- **Properties**: Number (read-only), date information
- **Events**: Mouse handling, click processing

### Key Implementation Details

- Use "m" prefix for member variables
- Keep parent reference for communication
- Store class instances in form-level collection
- Implement proper cleanup in form unload

## Event-Driven Architecture

### Traditional vs. Event-Driven Approach

Anders used a brilliant analogy: announcing "fire" in a room versus individually telling each person to exit. Event-driven design:

- Broadcasts announcements (RaiseEvent)
- Lets listeners decide how to respond
- Doesn't require knowing who's listening
- Prevents errors in one listener from affecting others

### Custom Events Implementation

```vba
' In parent form
Public Event MonthChange(MonthID As Long)
Public Event MouseOver(obj As Object)

' In class
Private WithEvents mParent As Form_Calendar

```

## Advanced Features Demonstrated

### Mouse Interaction

- Highlighting current date under mouse
- Neighboring cell highlighting for better UX
- Performance optimization (only update when needed)
- Defensive coding with TypeOf checks

### Multi-Form Communication

- Calendar broadcasts date selection events
- Production and sales forms listen independently
- Forms can open/close without breaking others
- No tight coupling between forms

### Embedded vs. Standalone

- Same classes work in both scenarios
- Sub-forms automatically inherit event listening
- Parent forms handle setup and cleanup

## Memory Management and Cleanup

### Circular Reference Problem

- Form holds collection of class instances
- Classes hold reference back to parent form
- Prevents automatic garbage collection
- Causes "object in use" errors

### Solution: Explicit Cleanup

```vba
Private Sub Form_Unload(Cancel As Integer)
    Set DateDisplays = Nothing
End Sub

```

### Debugging Tip

Add debug statements to class Terminate events to verify proper cleanup.

## Practical Applications

### Date Table Benefits

- Supports holidays and fiscal years
- Enables complex date calculations
- Improves SQL Server performance dramatically
- Can be replaced with calculated dates if needed

### Real-World Usage

Anders demonstrated filtering multiple forms simultaneously based on calendar selection, showing how event-driven design scales naturally to complex scenarios.

## Best Practices Highlighted

### Property vs. Variable Design

- Use properties when setting triggers other actions
- Properties enable validation and side effects
- Variables for simple storage

### Error Handling in Events

- Unhandled errors break entire event chain
- Proper error handling allows other listeners to continue
- Each listener operates independently

### Performance Considerations

- Only update properties when values actually change
- Access does significant work on control property changes
- Defensive checks prevent unnecessary updates

## Conclusion

Anders effectively demonstrated how classes can transform Access development from repetitive, maintenance-heavy code to elegant, reusable solutions. His calendar example showed practical benefits while the event-driven architecture illustrated how classes enable loose coupling between forms. The presentation proved that even Access developers, who often rely on forms and bound controls, can benefit significantly from object-oriented programming concepts.

## Recording

The full recording is available on [YouTube](https://www.youtube.com/watch?v=9chkPUVdvcw):

## Join Live!

Want to get even more out of these presentations? Join the live Access User Group events! The next upcoming events are listed on the [AUG Event Calendar](https://accessusergroups.org/calendar/?ref=nolongerset.com).

Attending live gives you the opportunity to:

- Interact directly with presenters during Q&A sessions
- Network with other Access developers
- Share your own experiences and challenges
- Get immediate answers to your specific questions
- Participate in group discussions

With multiple user groups across different time zones (and languages!), you're sure to find a meeting time that works for your schedule.

## Acknowledgements

- *Base cover image generated by FLUX-schnell*
- *Initial draft generated by Claude-Sonnet-4*