joyfullservice / msaccess-vcs-addin

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

FSO.GetDrive(strDrive) in GetUncPath of modFileAccess sometimes causes error #368

Closed ollypsilon closed 1 year ago

ollypsilon commented 1 year ago

https://github.com/joyfullservice/msaccess-vcs-integration/blob/c966b3427d752cb8c82e56c0c2cce6d5af45b362/Version%20Control.accda.src/modules/modFileAccess.bas#L454

For some reason GetDrive in some cases causes an unhandled exception. This leads to error 5, causing database properties not being exported.

But when calling this function isolated, e.g. in VBA window, all is fine: image I've created a copy of this function. In screenshot one can see that line 3 it was working when executed directly after loading database. Line 2 shows the result while running the add-in.

Maybe I find time to dig deeper, for now I have simply disabled this function call.

OS: Windows 10 Enterprise, 64 bit, 22H2, build 19045.2130 Access: Microsoft® Access® für Microsoft 365 MSO (Version 2210 Build 16.0.15726.20188) 64 Bit Add-in: Version Control v3.4.23

hecon5 commented 1 year ago

This is a nuanced issue, and my pr #363 Should help to fix it.

I think it's actually because in Windows 10, FSO object isn't correctly instantiated the first time and a retry is required. In my deployment, I've actually got this fixed a few ways:

  1. Try getting FSO 3 times (third time's the charm); I almost never get FSO errors after this.
  2. Verify the drive is actually connected before carrying on. In network drives (especially if you use VPN/remote work), there's a very good chance upon login the drive isn't actually connected.

Both of these are fixed by the PR;

See Lines 25-61 and 561-615 of my pull request for a way to patch your instance and see if that fixes it.

joyfullservice commented 1 year ago

I ran into this today, and found a problem if you try to call the GetUncPath function on a relative path. (Such as a relative database icon .\my_logo.ico.) The fix was to simply avoid trying to return a drive object from an empty string. 3b9809c

Not sure if this is related to the original issue here...