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

Import one file #406

Open santiobarco opened 1 year ago

santiobarco commented 1 year ago

I need update just one file in the application, I have a change in one form, what I need to do?

joyfullservice commented 1 year ago

@santiobarco - Great question! There are two approaches you can take in the latest beta version. (Version 4.0.13-beta that I just published today)

From the ribbon, you can click the button to Load Selected. That will reload that item from the source file.

image

The other option is to perform a Merge Build, a newly developed feature which will scan your source files for changes that do not exist in your database, and import any changed source items into the database. (This is typically much faster than rebuilding the entire database from source.)

image

I hope that helps!

santiobarco commented 1 year ago

Thanks for your faster answer, I have an other question, If I want it to compare the existing files and only change the ones that have changes I can do it too, I try to do a merge because I just added some public sub in one of the existing modules and it tells me that I should build from source first

joyfullservice commented 1 year ago

Yes, that would be correct. In order to merge from source, you need to do a full build from source first. Once you have done the initial full build, you can export and merge as often as you like.

santiobarco commented 1 year ago

Thanks I will try it!!

santiobarco commented 1 year ago

This does not make a comparison of a file with another, I mean if a new module was created to a new function, etc.

joyfullservice commented 1 year ago

@santiobarco - Perhaps I am not quite understanding your question... Let me try to explain what I think you are asking, and you can help me understand.

You have a database, let's call it Database.accdb. You have used this add-in to export the source files to Database.accdb.src. In the source files folder, you have modified one of the existing source files, Module1.bas to include a new VBA function. Now you would like to update Database.accdb to include this new change from Module1.bas.

What you are dealing with here is a change to the source files that you would like reflected in your database. Up till just recently, the way you would do this is to build the database from source. This would reconstruct the database from the source files. After building from source, Database.accdb now includes the new function in Module1.bas.

A new functionality just recently introduced (currently in the dev branch) allows you to merge build, which scans your source files to identify changes that do not currently exist in Database.accdb. During this scan, the add-in would detect that Module1 has changes in the source file that do not match Module1 in the database. Assuming that Module1 in the database has not changed since the last time it was exported, Module1 would be recreated from the source file. Now Database.accdb includes the changes from Module1.bas, without having to perform a full build of the database. (Note, in order to perform a merge build, you must have done a full build at least once.)

Let me know if this makes the process more clear...

santiobarco commented 1 year ago

Hi @joyfullservice I need to build from source for merge a new changes, but when start the process for build from source the application stays frozen, do you have some advice for make this please

joyfullservice commented 1 year ago

Which version of the add-in are you using? Also, are you able to build other databases from source? (For example, if you create a very simple new database file, can you export that to source files, then build it from source?)

santiobarco commented 1 year ago

Thanks a lot for the quickly answer I need to solve this now, I use the version 4.0.15-beta and I try to build from source with a simple database and i'ts working with a simple file

joyfullservice commented 1 year ago

You could try the build with or without the Debug VBA Errors option to see if that helps identify the problem...

image

When it freezes, are you able to press ctl+break to stop the running code? Can you tell where the build is struggling to continue? What is the last thing you see on the screen before it gets stuck? These clues may help us pinpoint where the problem is occurring.

santiobarco commented 1 year ago

Ok adam I'll try right now!!

santiobarco commented 1 year ago

Adam the process is freeze when start the import of the forms

joyfullservice commented 1 year ago

Okay, let's try to figure out what is happening with the form import... Here are a couple things you could try:

Using the existing database, try importing the forms one by one using the Load Selected button on the toolbar. This might help us see if it is affect all the forms, or just certain ones. To do this, select the form in the navigation pane, then click the Load Selected button to reload that individual object from the source file.

A second thing you could try is to go to your simple test database, and use Microsoft Access to import the forms from your big database into your test database. After importing the forms, export the test database to source files, and then try building from source. If it still freezes, then remove all the forms from the test database and try just importing one or two of the most simple forms from the big database.

The goal here is to identify a form that is failing to import, then to figure out what might be causing it to fail. You can also add breakpoints in the VBA code for the form import process (see clsDbForm), and step through the code as it performs the import to see if that helps identify exactly where the code is failing.

Let me know what you find out!

santiobarco commented 1 year ago

I have more than 100 forms import one by one is not a option, I tried again to build from source and press ctrl + break for see the debug vba Errors but this shortcut is not working.

joyfullservice commented 1 year ago

Yes, I can feel your pain with that. The main thing I am trying to identify is if the form import issue is related to ALL of the forms, or just some of them. You probably won't need to import all 100 forms one by one. You might just need to test a few of them to find one that exhibits the issue. From there you can drill down and isolate issues until we can figure out exactly what is causing the import to fail.

If you can find ONE form that fails to import, that you can reproduce with your testing database, it will make troubleshooting the problem a lot easier. My guess is that there will be something we can do to resolve the issue, but we just need to figure out what the problem is first. 😄

santiobarco commented 1 year ago

I got you adam thanks for all the help, but I tried with 10 of that but don't have any problem them. I'll keep trying

santiobarco commented 1 year ago

Ok adam I find the form that have issues, how handle this, I have the name of the form

santiobarco commented 1 year ago

But I make a mistake and block the add-in for because I made many times frozen the app, how we enable again the vcs add-in

joyfullservice commented 1 year ago

If you want to provide a small sample database, I could test it on my system. Otherwise you will need to set some break points in the VBA add-in code to step through the import process.

Regarding the add-in, try reinstalling it and see if that resolves the block. If not, you might need to figure out how to unblock it again first.

santiobarco commented 1 year ago

Adam thanks for the help, when I tried to add-in the VCS, i get this system message is missinig a USysreginfo table, do you know where I need to create this table?

joyfullservice commented 1 year ago

That's for a different kind of installation. This add-in doesn't require that table (or admin privileges to install). Just double-click the downloaded add-in file, and click the button to install when it opens.

santiobarco commented 1 year ago

Adam I Made the installation again, but I can't see the VCS in the ribbon is weird

joyfullservice commented 1 year ago

Adam I Made the installation again, but I can't see the VCS in the ribbon is weird

There are two parts to the installation. The Microsoft Access add-in is installed, and available via the ribbon, and via the Add-ins menu. If you can launch the add-in using this menu, you know that the Access add-in is working.

image

The second part of the installation is the COM add-in, which is installed a different way. (Access add-ins are literally Access database files with VBA code, while a COM add-in is a compiled DLL, in this case created with twinBASIC.)

To view/manage the COM add-ins, you navigate to the application options:

image

There you will find the COM add-ins listed, and an option to load/unload or remove.

image

You mentioned that something was "blocked" at some point when you were testing... I don't know which thing was blocked, or exactly how it was blocked. Normally the installation is very simple. One click and you are done. 😄 You may need to go to the COM add-ins and remove the existing item, then run the (Access add-in) installation again to see if the installer will reinstall it for you.

Again, to install/reinstall, simply double-click Version Control.accda and click the Install button. That should handle extracting and installing the COM add-in, registering and activating the ribbon, etc...

Hope that helps!

santiobarco commented 1 year ago
aa

Adam I made the installation again but I can't see the VCS in the ribbon

joyfullservice commented 1 year ago

What do you see in the COM Add-in dialogs shown in the screenshots above? The COM add-in is what loads the ribbon. If the COM add-in is not loading, you won't see the ribbon.

santiobarco commented 1 year ago
image

Adam I can see the ribbon thanks a lot I'll still investigate the form that have the problem, thanks a lot for them, when I got some news about the form I'll keep in post to you

sotalvaro commented 1 year ago

Hi Adam, can you guide me when you executes the Build as button I need execute a routine and integrate internally all this flow, but I need to overwrite always with the same name of the original version, just need to build the new app with the same original name and overwrite, for don't create more copies inside the folder.

How can I modify the code? I need make the Build As routine will execute when is determine user.

Another question @joyfullservice why when I just open the access file I'm unable to see the vba code of VCS.

image

Thanks for your help man.

joyfullservice commented 1 year ago

There are two types of add-ins that work together for this. The COM add-in is what contains the ribbon commands, and is loaded when you open Microsoft Access. This stays loaded all the time. (This is developed in twinBASIC and installed as a compiled DLL.)

The Access add-in is a Microsoft Access database project that contains the main logic for exporting source files and building a database from source. Unlike the COM add-in which is loaded all the time, this add-in is loaded on demand when it is first used. After the Access add-in is loaded, it stays loaded until the application is closed.

The reason you don't see the MSAccessVCS project in the screenshot above is because it has not yet been loaded in this instance of Access. When you click one of the VCS ribbon commands, the Access add-in will be automatically loaded, and you will see it listed in the VBA projects list. The internal Access wizards work the same way. Once you run a wizard, that add-in stays loaded in Microsoft Access until the application is closed.

To find the code that is executed when you click a button on the ribbon, take a look at the clsVersionControl class module. There you can find the BuildAs() function, and see exactly what the code is doing.

You mentioned needing to execute a routine and internally integrate this workflow. I am not sure that I completely understand what you are wanting to do, but here are a couple things that may be helpful:

I need to overwrite always with the same name of the original version, just need to build the new app with the same original name and overwrite, for don't create more copies inside the folder.

A normal build does exactly that, replacing the existing database with a freshly built version. The "copies" in the folder are backups of the database before each build. If you really don't want the backup files, you can add some code to delete the backups and trigger it to run after the build process.

Hope that helps!

sotalvaro commented 1 year ago

Hi Adam Thanks for the quickly answer, here is the thing that I need to do, I need to run the build as process automatically, because I set up a pipeline in azure dev ops and the release open the access file, when the access file is open I need to validate the user that is open the file (The user of the pipeline of azure dev ops) after that I need to, run the build as process always in the same path and overwrite the file with the same name.

joyfullservice commented 1 year ago

As of the latest commit, you should have everything you need to do this, but you will obviously need to work through the specifics in your particular build process. To launch the add-in and initiate actions, please see ExampleLoadAddInAndRunExport() in modAPI. The specific commands you will want to run are:

MSAccessVCS.SetInteractionMode 1   ' Set to silent
MSAccessVCS.HandleRibbonCommand "btnBuild"

This will run the same action as clicking the "Build From Source" button on the ribbon toolbar. (To build the current database from source.)

I would highly recommend using the standard build operation, not the Build As for automated builds. You can check out the project to a build folder in your deployment pipeline, and then after building from source, you can test/verify your file, then push it out to whatever distribution system you have set up. You may also want to add some automated checks to review the build log file to check for any errors.

If you have further questions/issues with the build automation, please feel free to open a new issue for that. I think we have pretty well resolved the original issue of importing one file. 😄

I am planning to roll out a new dev release today (4.0.21), so that should include all of the latest commits needed to perform an automated build.

sotalvaro commented 1 year ago

Adam Thanks for the answer. If I need to execute the same routine that you post in there I can see the in the same method? but i need to change just this MSAccessVCS.Exportsource for what word man.

image

Just need to change right this

image

And i'll create the new issue hehe