[AccessD] A diff program for Access?
fuller.artful at gmail.com
Fri Nov 12 11:08:02 CST 2021
Good policy. My own is similar. I use static functions to retain the values
of interest. In general, I use the OnClick event of some button, let Access
generate the code, and then replace all references to Me.xxx with calls to
the relevant static function. I have a primitive template that contains
templates for statics that get/set all the data types, then just copy the
one I need, name it, and then MZ-Tools writes the header and error handler
There is a replacement (heh heh) for Rick Fisher's Find and Replace. It's a
lot better but not free. That's ok by me. Even your average chef brings her
own set of knives to the kitchen. It's the cost of doing business.
Following is the "master template " I use for creating static functions.
' Procedure : CurrentX
' DateTime : 04/09/2005 20:37
' Author : Arthur Fuller
' Purpose :
' : Copy this template each time you need a new set/get function
' : Then Replace "X" with the name of your object, i.e.,"Employee"
' : Replace all in current proc and un-comment the code and
' Notes : To call such a function, you can do it in three ways:
' : 1. Set: pass a parameter, e.g. CurrentX(123)
' : 2. Get: pass no parameter, e.g. CurrentX() 'retrieves the
last set value
' : 3. Re-initialize: pass -1 to set the value back to null
'Static Function CurrentX(Optional lngNew As Long) As Long
' Dim lngCurrent As Long
' On Error GoTo CurrentX_Error
' If lngNew <> 0 Then lngCurrent = lngNew
' CurrentX = lngCurrent
' #If conDebug = 1 Then
' Debug.Print "Current X: ", CurrentX
' #End If
' On Error GoTo 0
' Exit Function
' MsgBox "Error " & Err.Number & " (" & Err.Description & ")" & _
' vbCrLf & _
' "in procedure CurrentX of Module CurrentValues"
As the header indicates, you copy this template and replace "X" with, say,
"CustomerID" or ""ProjectID" or whatever you need.
My general approach is to place all these static functions in a single
module called, unsurprisingly, "Static Functions".
For those unfamiliar with static functions, they work pretty much like
Globals, but with an important difference. There is only one way in and
only one way out. No chance that your code could clobber the values
In subs or functions that may need these values more than once, then at
the top I grab the current values and store them in local variables.
Dim lngCustomerID as Long
Dim lngProjectID as Long
lngCCustomerID = CurrentCustomerID()
lngProjectID = CurrentProjectID()
lngCustomerID = CurrentCustomerID()
.. more code
This way, I skip the overhead of repeated calls to the static functions.
Grab their values once, then proceed. Without danger of anyone or any code
accidentally changing the value of a Global.
On Fri, Nov 12, 2021 at 10:53 AM Rocky Smolin <rockysmolin2 at gmail.com>
> I have the old mdbdiff program which works on mdb files and works well on
> tables but does not do code. I can send it to you if you like.
> I really miss Fisher's Find and Replace. That program was a gem. I used it
> a lot back in the day and could have used it this year looking for
> occurrences of something across all objects. But, he's gone and my copy of
> F&R stopped working.
> Finding subs and functions never called is easy - just do a global find in
> the VBA editor of the sub or function name. If it doesn't appear anywhere,
> delete it.
> I agree with you about passing parameters to a called form versus grabbing
> the needed value from an open form. So now I use code:
> DoCmd.OpenForm "frmActivityComments", , , , , , Me.fldMAID
> where fldMAID is a Marketing Activity, and form frmActivityComments is a
> table of comments associated with the marketing activity.
> in frmActivityComments the open event has the lines:
> Me.Filter = "fldMAID = " & Val(Me.OpenArgs)
> Me.FilterOn = True
> to set a filter in the called form.
> Or to find a specific record:
> If Not IsNull(Me.OpenArgs) Then
> Me.RecordsetClone.FindFirst "fldDiscussionLeaderID = " &
> Me.Bookmark = Me.RecordsetClone.Bookmark
> End If
> I began using this approach when I found that a form in my app could be
> called from more than one place. So instead of using the IsOpen function to
> find out which form it was, I instituted a polocy of always passing the
> parameter of the record or the filter from the calling form.
> On Fri, Nov 12, 2021 at 6:27 AM Arthur Fuller <fuller.artful at gmail.com>
> > I don't suppose there exists such a thing, but who knows, there may be. I
> > want to determine the differences down to every level between App A and
> > B. Is there a tool that can do that, or am I forced to walk hand by hand
> > through hundreds of modules, forms, queries and reports.
> > This app has grown gargantuan over the years, and this is a very bad
> > Perhaps the first thing I need to do is identify all the "dead code" --
> > subs and functions never called in the current implementation
> > Next, I want to employ a technique I learned from Jim Dettman: forget the
> > behemoth app model and instead create Microservices that do one thing,
> > as deliver a report. On occasion, this is not trivial: Access seduces you
> > into thinking that reference to some open form are cool. I most
> > emphatically disagree. If a Report needs parameters, then pass them, or
> > alternatively refer to the return values of Static Functions.
> > I think that I may be going against the stream here. So be it. I like to
> > use the Access Wizards to create the basic code, but immeiately after
> > I separate the generated code for the button from the button itself,
> > creating a new sub or function and changing the btton code to cal that
> > or Function. as a result, al the form/button-clicks are reduced to one
> > of code, not dependent upon the form whose buutton invokes a local event.
> > NOT my way of coding. I choose to ship everything possible away frrom the
> > form and refereences to its avlaue, and eventually all the code away from
> > the form into a module that I can call from anywhere, given expected
> > parameters.
> > --
> > Arthur
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> AccessD mailing list
> AccessD at databaseadvisors.com
> Website: http://www.databaseadvisors.com
More information about the AccessD