7
votes

What is the actual encoding used in Access' VBA editor? I have been searching for a concrete answer for quite a while but with no luck.

I thought it was UTF-8 but I'm not very certain.

My main issue is that when writing a query in VBA I sometimes need to test it in Access' query editor. When copy-pasting however, I lose my native characters (greek in my case) as they turn to gibberish.

I have tried pasting in a text editor and saving it as different encodings but I can never recover the original characters.

Thanks in advance.

Edit

Let me explain this a bit further:

As you can see I can write my greek characters in the VBA editor normally:

sample in vba editor

However, copying the first line in Access' query editor, I get the following:

paste in query editor

Same goes for a simple text editor:

text editor

So I am inclined to think that the problem lies inside the clipboard, due to the encoding used for the greek characters. I guess they are not Unicode, as I indeed have to make the change in the System Locale for non-unicode characters. So how are these characters saved/copied? In what encoding?

Answer

Actually this problem was solved by switching the keyboard input language to greek (EL), when copying the actual test string.

I am still not sure however, as to why that happens. If anyone can provide some insight into this, I would love to hear it.

Thanks again

4

4 Answers

6
votes

The VBA editor does not support Unicode characters, either for input or display. Instead, it uses the older Windows technology called "code pages" to provide support for non-ASCII characters.

So, the character encoding in the VBA editor corresponds to the code page that is used by the Windows system locale as specified in the "Regional and Language Options" control panel. For example, with my system locale set to "Greek (Greece)"

cpGreek.png

I can enter Greek characters into my VBA code

vbaGreek.png

However, if I switch my Windows system locale back to "English (United States)"

cpUS.png

and re-open my VBA project, the Greek characters have changed to the corresponding characters in the new code page

vbaUS.png

3
votes

If "Control Panel" -> "Regional and Language Options" -> "System Locale" is set correctly but you still suffer from this problem some times then note that while you're copy-pasting your keyboard layout must be switched to the non-English language.

This is applicable to all non-unicode-aware applications not only VBA.

Credit goes to @parakmiakos

0
votes

details in this: http://www.pcreview.co.uk/forums/use-greek-characters-visual-basic-editor-t2097705.html

Looks like making sure your OS is set properly, and font choice inside the VBA editor.

0
votes

I had a similar problem with Cyrillic characters. Part of the problem is solved when set the System locale correctly.

However, The VBA editor still does not recognize cyrillic characters when it has to interpret them from inside itself.

For example it can not display characters from the command:

Msgbox "Здравей"

but if the sheet name is in cyrillic characters it does it well:

Msgbox Activesheet.Name

Finally, it turned out that these kind of problems were solved when I changed to 32 bits version of MS Office.