joyfullservice / msaccess-vcs-addin

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

Temp file path becomes invalid as filename parameter contains path already #381

Closed ollypsilon closed 1 year ago

ollypsilon commented 1 year ago

https://github.com/joyfullservice/msaccess-vcs-integration/blob/6fedf269e9593b4ad043ab35b43b8b819ef71c32/Version%20Control.accda.src/forms/frmVCSConflictList.bas#L502

I just tried to use the "Show Differences" option and got a VBA error due to path is invalid image image

This is due to strFile is converted from filename to full path with strFile = Options.GetExportFolder & strFile When this is changed to use the initial filename it works as expected: strTemp = VCSIndex.GetTempExportFolder & txtFileName image

joyfullservice commented 1 year ago

Thanks for pointing this out! This is a very good example of what can happen when I don't use clear variable names. Oops. 🤦‍♂️

I reworked the variable names to more clearly state what they mean, and fixed the code in several place to properly handle these paths. This should be working correctly now, but let me know if you encounter any more problems with the diff tool.

mwolfe02 commented 1 year ago

@joyfullservice FYI, I use an "Apps-Hungarian" naming convention for my file path variables because I got tired of tracking down what portion of a filename was in a file path variable: My File System Variable Naming Convention for VBA.

joyfullservice commented 1 year ago

@joyfullservice FYI, I use an "Apps-Hungarian" naming convention for my file path variables because I got tired of tracking down what portion of a filename was in a file path variable: My File System Variable Naming Convention for VBA.

Thanks Mike! I read your article and comments, and a good part of Joel's longer article as well. At the end of the day, I want the code to be as clear and readable as possible, and easy for myself or anyone else to understand at a glance what is going on. I have based my naming conventions primarily on what I learned from the Access 97 Developer's handbook some twenty years ago when I first started developing databases in Access.

I know most developers today frown on Hungarian style notation, but a lot of that goes back to the development environment IDE. In VSCode you can hover over a variable and see everything about it. How it was declared, what type it is, even comments connected with it. In the VBA IDE, not so much. Building some of this information into the name helps clarify what I am looking at, and whether I am working with a variable or a function. These old-fashioned prefixes are also very effective in avoiding the frustration of case switching in the VBA IDE when people interchangeably use the same name for variables and functions.

Obviously a lot of this comes down to personal preference and style. I enjoy learning about different approaches to these kinds of things. Moving VBA over to VSCode will probably change a lot of the archaic workarounds necessitated by the languishing VBA IDE, so it will be fun to see what happens with TwinBasic over the next few years. 😄