Eliminating Magic Numbers in VBA with Kim Young and George Hepworth
Please join us for our Monthly Chapter Presentation March 6, 2025, at 6:30PM Pacific (UTC -8)
Kim Young has agreed to join me in a discussion about preparing to take over an Access database from another developer.
We need to consider three view points during the process.
- The departing developer
- What can you do to make the transition smoother?
- What should you do?
- The incoming developer
- What can you reasonably expect from an inherited application?
- What can you ask the previous developer to do?
- What can you ask the client to do?
- The client who owns the database application.
- Why should the transition involve changes to an application that has been “working just fine”?
- How much should the client expect to spend on such transition costs?
I don’t have answers to all of those questions, but I do have opinions. Kim will also bring her extensive experience as a developer and as a product manager to the discussion.
In this discussion, we’ll outline some considerations that can make a transition easier or harder, and also some of the factors that make it more likely those considerations will get attention.
- Will a client want to invest development dollars in an application that “has been running just fine”, even if incoming developer can make the case for modifications or enhancements?
- Can an outgoing developer afford to invest time in preparation for a transition?
- Post transition, can an incoming developer afford to invest time in bringing the application into alignment with their standards and practices?
In this discussion, we’ll touch on things we believe are important to at least consider, such as naming conventions, coding standards or basic table design.
Along the way, I’ll bring in a couple of examples, such as VBA containing so-called “Magic Numbers”.
Eliminating “Magic Numbers”
If you’ve ever taken over an existing Access Relational Database Application, you might have encountered this problem. You find code with numbers like this:
lngPublisherID = Nz(.cboPublisher, 60)
What does 60 mean? Where did 60 come from? Why isn’t it 0? What did the original developer mean?
Compare that to this version:
lngPublisherID = Nz(.cboPublisher, enuDefaults.defPublisher)
And the light comes on. 60 is the Primary Key of the default Publisher assigned when the actual Publisher is unknown.
Replacing “Magic Numbers” is a self-documenting way to make your code more accessible to the next developer who looks at your code.
I’ll provide examples of places where I’ve found it relatively quick and easy to improve code with self-documenting alternatives to Magic Numbers.
In addition to Enums, I’ll introduce an class-based approach. Yes, after all these years, I’m finally getting my feet wet with Classes in VBA.
Bring to the meeting your own examples and ideas about making code more readable and understandable.
Access Pacific holds FREE Q&A webinars the First Thursday of every month, from 6:30 pm to 7:30 pm Pacific.
AUG Access Pacific Calendar .ics file
==============================================================================
Please prepare ahead of time by downloading Zoom, if you don’t already have it.
Get Zoom
To join our meetings, please use the following link and phone number or use your computer’s speakers with audio:
When it’s time, join the meeting from here:
Join Zoom Meeting
If you are asked:
Meeting ID: 852 1966 9601
Passcode: 123456
Dial by your location
+1 253 215 8782 US (Tacoma)
+1 346 248 7799 US (Houston)
+1 669 900 9128 US (San Jose)
+1 301 715 8592 US (Washington DC)
+1 312 626 6799 US (Chicago)
+1 646 558 8656 US (New York)
Meeting ID: 852 1966 9601
Passcode: 123456
Find your local number