Access JumpStart 2.0 | Blog

A Rapid Development Framework for Microsoft Access

Today’s Access adventure involved refactoring code as an evolution from getting a particular set of line item records associated with a file to be processed when that file was selected from another form.

In the first iteration of the code for testing, I was using a particular file ID I had hard coded into the routine as I tested. I was working in an app I’ll call Billing here.

From another app we will call Inventory, I had copied over a form (into Billing) that would display files and allow the user to select which records should be processed based on which files they came from. I had to change that code in Billing a bit to get it working, but it was pretty simple as they use the same source database.

So I had already accomplished that, and I needed to refactor the existing Billing test code and put it into the copied file processing routine in the Billing system, replacing the old code.

Using polymorphic objects (I had already created a class interface that defined a file import object, and was then able to create a new class object based on this interface and easily insert it into the application), I was able to add in a new file type processing object that matched my test routine. My test routine was already in a subroutine, so I moved it into the processing class and took the static file ID and made it a parameter of the subroutine. The polymorphic interface already passed in a file id so I was simply able to call the subroutine with the file ID and away it went.

I discovered in the process that some of the files of the same type were not importing, but that is a project for another day…

Sign up For a Daily Email Adventure in Microsoft Access

Every business day (typically M-F), I'll send you an email with information about my ongoing journey as an advanced Access application developer. It will be loaded with my tips and musings.

    We won't send you spam. Unsubscribe at any time.