Forum Discussion
Access changing lettercase - redux
Here's what's going on. This is informed by my having gotten my start on Dartmouth Basic in the late 60's and realizing that the basic (pun intended) operation of tokenization hasn't changed in almost 60 years, at least in VBA.
- Your BASIC statements are compiled to a tokenized intermediate representation that is easy to interpret. This happens every time you "commit" a statement by pressing ENTER or moving the cursor away from the line. In the tokenized form, names are stored as references into a symbol table.
- There is one (and only one) symbol table (i.e. namespace) where ALL names are stored.
- A symbol table entry contains a case-sensitive spelling of every name. However, when the table is searched, the comparisons are case-insensitive.
- There can be many objects with the same (case-insensitive) name, in different scopes, but only a single entry in the table for a given name, and that entry contains the current case-sensitive canonical spelling of the name.
- When you enter a statement that "creates" a name (Dim, Sub, Function, Const, etc) the canonical spelling in the symbol table gets updated to the spelling you just typed. If you accidentally type a name that differs only in lettercase from an existing name, the symbol table gets updated with the new spelling.
So this explains how the symbol table gets updated. The next bit explains why this affects names in seemingly unrelated places.
The crucial point is that what you see in the editor is not the code that you typed
- Remember that every time you enter a statement it gets tokenized to binary opcode(s) and symbol table references. What you typed is actually discarded (except for comments).
- As soon a statement is committed and tokenized, the process is reversed and the VBA source code version of the statement is recreated. As part of that process, any names are retrieved from the symbol table.
So, committing a "name-creating" statement updates the symbol table with the current letter-case spelling of the name. This seems to trigger a global "decompile" step that updates all existing statements that refer to the changed name, which immediately affects any open code windows.
Whenever you perform any operation that involves displaying source code (open a code module, export source), the VBA source gets regenerated from the stored tokenized version, using the current letter casing from the symbol table. So changing spelling on one place affects all references to that name.
To "fix" what you perceive as broken lettercasing for a specific name, all you have to do is "commit" a "name-creating" statement with the correct letter case. It makes no difference what that statement is, even a simple Dim will work.
So, back to my example:
- I inadvertently typed Sub class_initialize(). Since this is a "name-creating" statement, the symbol table was updated to make the canonical spelling all lower-case.
- All other instances of Class_Initialize() were changed to lower-case
- To fix it, all I had to do was enter Dim Class_Initialize as Long, commit the statement, and then delete it.
Problem solved.
- George_HepworthApr 27, 2025Silver Contributor
For information.
The Access team at Microsoft does not own VBA. VBA is owned by the VBA team.
While it is highly annoying that this name changing behavior occurs in VBA when used in Access, it's not directly an "Access" problem. I suspect that developers using Excel, Word, et al are equally annoyed when it happens.
But ultimately, the complaints need to be directed to the responsible team to have a chance of being addressed.- jhg-goowApr 27, 2025Copper Contributor
OK, so I posted my feedback using the "official" channel, the Feedback function in Access.
It got posted to Access, not VBA.
So the question remains: How does one post feedback that will reach the VBA team?
- jhg6308Apr 27, 2025Copper Contributor
... And the feedback portal is broken. I have two Microsoft accounts, one personal and one for a non-profit for which I do volunteer IT work. In Access I'm logged in with my personal account, but the feedback portal submitted my comment as my non-profit login. Now when I go to the feedback portal it defaults to my personal account, but if I logout and try to login so I can change accounts, it never asks for a userid, just re-logs in as my personal account.
Identity management in a web app is a long-solved problem. Why is Microsoft having trouble with it in 2025?
- jhg6308Apr 27, 2025Copper Contributor
But ultimately, the complaints need to be https://learn.microsoft.com/en-us/office/vba/articles/feedback-support to have a chance of being addressed.
As you're well aware, that link goes to a page saying we should use the Feedback option from within the app. I.e. there's no forum, just a "feedback black hole" where suggestions and complaints go to die.