There are times in my job that I wished I had photographic memory. I primarily code in Microsoft Visual Basic for Applications (VBA) and in MS Access SQL (or other flavours depending on the client.)
As with all programming langauges, there are a lot of words to memorize. I suspect that I only use a small fraction on a daily basis.
For comparison, did you know that according to Oxford Dictionary there are 171,476 English words in current use.
Robert Charles Lee writes on Quora that the average adult native speaker of English knows 20,000 to 35,000 words. Also, that “3,000 words will cover 95% of everyday writing.”
Of course, some of those words we use are ones that are not always appropriate in certain situations…
There I was, trying to run a Stored Procedure (a SQL command I’d saved in MS Access) from VBA and all I got was this error:
“The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.”
Okay, what does that mean, apart from the obvious? The SQL was working fine when I ran it directly within the Access database. I only received the error when running through VBA.
I went and poured myself a coffee. Decaf…
Reserved word, misspelt or missing argument name, incorrect punctuation… One of those must be true, but why was the SQL query running on the database?
I took a closer look and finally realised what I’d done wrong. The query was returning a list of Transactions and so I’d called the name of the Transactions: Transaction. I searched online and found this handy list of Reserved Words.
Transaction, of course, is reserved. If you know more than basic SQL that is probably pretty obvious. A feature of SQL is that it allows you to combine commands within a “Transaction” which can then be rolled back if something goes wrong.
So, using Transaction as a column name is not allowed. What I’m left wondering is why MS Access allowed it… Maybe one for another day.