What have I done that has impacted the capitalisation of my ubiquitous variable? (2 Viewers)

peskywinnets

Registered User.
Local time
Today, 00:14
Joined
Feb 4, 2014
Messages
585
ok, I'm sure this is embarrassingly simple, but...

I use the string variable strSQL = all throughout my code / modules & until quite recently that how it looked strSQL, but something has changed over the past week (and it's sure to be something I've done inadvertently)...the same variable in every bit of code has changed to strSQl (lowercase "l" at the end ...it's bugging me to look at (eye muscle memory after soooo many years!).

What should I be hunting for to find the rogue entry & restore my variable to the rightful strSQL

thanks in advance!
 
You may have typed the lower-case L in a circumstance with auto-correct turned on. What is the scope of that variable? Is it a local variable and you just re-use the name? Or a global (Public) variable with a single point of definition and it gets used from many places but is always the same Public definition in some general module? In any case, it is probably an auto-correct thing and you can find the place where it is defined, be sure auto-correct is on, and manually correct the definition i.e. where it is DIM'd / declared. Then turn off auto-correct unless you really feel you need it. But also if you don't use auto-correct, it would be good to be sure you DO have Option Explicit in your modules.
 
that's just it - I don't know (I'm not really much of a programmer, so never fully wrapped my head around all the options when it comes to this type of thing (indeed most of the time I just let access work out that it's a string from the fact the data is in quotes vs defining it at the top of my code - yeah, yeah, i know...I know!)

So, if I define it as a global variable then will that wrestle it back to looking like the former "strSQL" again?
 
Last edited:
What should I be hunting for to find the rogue entry & restore my variable to the rightful strSQL

It is an artefact of the editor.

Just type somewhere
Code:
Dim strsql
and all strSQL is changed to strsql.

The type somewhere
Code:
Dim strSQL
and all is restored to strSQL.
 
The first time I saw this happen, it was for a Public Enum list where the names of my enumerated symbols would change case if I accidentally hit caps lock and typed the full name, not even as a definition but as a reference. It is NORMALLY an auto-correct action on a public variable but only because the scope of a Public variable is, well... public. But as @lmb points out, the VBA editor is quirky with the querty.
 
The same issue can affect built-in function names like Left being changed to left, Right to right etc

The cause is Access trying to be helpful by correcting where you re-type something with the 'wrong case'. Usually it works well.
Unfortunately this can also have the side effect of overwriting the correct version for the reasons explained above.

Its happens so often that the excellent VBE_Extras add-in even has a Fix Case feature for just this reason.
It works by doing EXACTLY what Tom described in post #4

1770073794714.png
 

Users who are viewing this thread

Back
Top Bottom