joyfullservice / msaccess-vcs-addin

Synchronize your Access Forms, Macros, Modules, Queries, Reports, and more with a version control system.
Other
210 stars 41 forks source link

Reading `CurrentProject.Connection` crashes on my Access 2019 #316

Closed kenjiuno closed 2 years ago

kenjiuno commented 2 years ago

Hi, thanks for providing great add-in! I want to see this add-in workable on Access 2019 (64-bit)

I'm trying to use on:

My steps:

I debugged add-in.

It seems that reading from CurrentProject.Connection immediately leads to crash.

2022-04-08_14h37_20

Alternatively reading from CurrentProject.IsConnected seems to be safe (no crashing) for now.

This behavior is not related with add-in. Probably this is Access's problem.

As a workaround I have replaced CurrentProject.Connection Is Nothing with Not CurrentProject.IsConnected wherever it can be applicabled. And this workaround seems to work on my environment.

This problem is specific to me? Otherwise anyone having this kind of problem too?

hecon5 commented 2 years ago

I wonder if it has something to do with your character mapping.

If you can't Debug.Print CurrentProject.Connection or ?CurrentProject.Connection (causes Access crash) in the immediate window, I'm suspecting it's Access's problem and has something to do with the character set / language interpretation.

Would you try an experiment?

  1. Change your machine's in-use language to English (or any other language using the Latin Alphabet you're comfortable in, the goal is to test and see if the specific language character set is at fault).
  2. Restart your machine (this will hopefully flush out any lingering language processes).
  3. Restart Access (in the AddIn or just open a new database as you did above).
  4. Attempt to read the connection.
  5. Report results.
kenjiuno commented 2 years ago

Hi, thanks for reply!

I have tried to apply some English settings, however it doesn't help for now. For now I have no good idea to improve this situation, sorry:

access

I agree that this problem comes from Access's problem (this is not addin problem).

2022-04-08_23h21_46

2022-04-08_23h22_16

2022-04-08_23h22_28

2022-04-08_23h25_06

hecon5 commented 2 years ago

I see above that Access IDE is still showing Kanji when this happens; it's making me suspect it refuses to change, and that the language interpenetration is at fault here. After you change language settings, does Access still show in Japanese? If so, I'm flummoxed as to why, and also how to change it.

kenjiuno commented 2 years ago

I see above that Access IDE is still showing Kanji when this happens; it's making me suspect it refuses to change, and that the language interpenetration is at fault here. After you change language settings, does Access still show in Japanese? If so, I'm flummoxed as to why, and also how to change it.

Yes, Access continuously displays Japanese on English locale/display language.

Technically it is possible to display Japanese characters upon English system locale and English display language environment. Using Unicode version of Windows API will help it. For example, TextOutW.

The main reason of displaying Japanese texts in Access is that I have installed Japanese version of Microsoft Access. It is possible that Access setup deployed only Japanese text assets to Windows (English text asset is missing).

joyfullservice commented 2 years ago

@kenjiuno - Thanks for reporting this! The CurrentProject.Connection is actually an object, so it wouldn't normally print anything to the debug window. It is also a remnant from the ADP project support that was discontinued after Access 2010.

The references to this object has been removed in the dev branch, so it won't create any problems in version 4 and beyond. (Unless you are actually exporting from an ADP project, which would not be the case in any version after 2010)

To fix this in version 3.4.20, you will want to remove the references to this object since it is not relevant to your version of Access. I believe this will fix the issue for you, and avoid the crash that you are experiencing.

Here is how you can fix it:

image

(There should be four occurrences replaced.)

Following the above steps should allow you to hot-fix your copy of the add-in. That is one thing that I really like about having this add-in in this format. It makes it easy to adjust the source code and reinstall it on your system.

Let me know if you have any problems after making this change. 👍

hecon5 commented 2 years ago

Interestingly enough: CurrentProject.Connection property (Access) (updated Jan 2021) says that it's still an active component. Instead of an ADP connection, it now returns the Active X (ADODB) connection. We still use it in some of our databases (all 365 or Access 19), so it definitely works.

The default member of CurrentProject.Connection is ConnectionString, which I think is the crux of the issue, or a symptom. I can't tell. But I think the issue is due to something with language and Access installation. image

I also found a page on FMS which points to this same symptom (Can't access CurrentProject.Connection).

Then there's this OLD SO Thread: Why do VBA CurrentProject.Connection statements cause all my access databases to crash? which makes me think even more so that the install is borked, or has something to do with a missing language pack.

Removing the reference in the Addin will definitely get him going for now, but I think the fact it's not there is a symptom of other issues to be found later.

joyfullservice commented 2 years ago

Thanks @hecon5! Those are some helpful links.

kenjiuno commented 2 years ago

Hi @joyfullservice Thanks, I could apply workaround (removing And CurrentProject.Connection Is Nothing) successfully, and now I could export database structure to filesystem I was going to do! This VCS addin will help so much, thanks again!

ps. here is an unrelated topic, sorry if you might know that: pressing SHIFT key before opening Access will skip AutoExec macro. Bypass startup options when you open a database