From 07bc57ccaac96960bcc67cfbfa331d5502906f21 Mon Sep 17 00:00:00 2001 From: joyfullservice Date: Mon, 13 Nov 2023 15:48:48 -0600 Subject: [PATCH] Add change hook for options Used for special processing when certain options change. --- .../forms/frmVCSOptions.bas | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/Version Control.accda.src/forms/frmVCSOptions.bas b/Version Control.accda.src/forms/frmVCSOptions.bas index df1e3ac2..08870769 100644 --- a/Version Control.accda.src/forms/frmVCSOptions.bas +++ b/Version Control.accda.src/forms/frmVCSOptions.bas @@ -16,10 +16,10 @@ Begin Form Width =10080 DatasheetFontHeight =11 ItemSuffix =252 - Left =3225 - Top =2430 - Right =13890 - Bottom =14175 + Left =-25575 + Top =1500 + Right =-255 + Bottom =14085 RecSrcDt = Begin 0x79e78b777268e540 End @@ -4296,6 +4296,9 @@ Private Sub MapControlsToOptions(eAction As eMapAction) If eAction = emaClassToForm Then ctl = CallByName(Options, strKey, VbGet) ElseIf eAction = emaFormToClass Then + ' Check for any hooks on option change + OnOptionChange strKey, Nz(ctl.Value) + ' Set the option value CallByName Options, strKey, VbLet, Nz(ctl.Value) End If End Select @@ -4328,6 +4331,46 @@ Private Sub MapControlsToOptions(eAction As eMapAction) End Sub +'--------------------------------------------------------------------------------------- +' Procedure : OnOptionChange +' Author : Adam Waller +' Date : 11/9/2023 +' Purpose : A hook to run special code or processing when specific options are changed +' : from their existing values. Add any specific rules here. +'--------------------------------------------------------------------------------------- +' +Private Sub OnOptionChange(strName As String, varNewValue As Variant) + + Dim blnChanged As Boolean + + ' Determine if the option was changed + blnChanged = Not (CVar(CallByName(Options, strName, VbGet)) = varNewValue) + If Not blnChanged Then Exit Sub + + ' Define actual rules here + Select Case strName + + ' If a user turns on the option to split files + Case "SplitLayoutFromVBA" + If varNewValue = True Then + If Git.Installed Then + If Git.IsInsideRepository Then + ' Prompt user with suggestion + If MsgBox2("May I make a Suggestion?", _ + "This project appears to be within a Git repository. This add-in includes a special utility " & _ + "that can split the files (layout and VBA) while preserving this history of previous changes in BOTH files.", _ + "Would you like to see additional information on this from the wiki?", vbQuestion + vbYesNo) = vbYes Then + FollowHyperlink "https://github.com/joyfullservice/msaccess-vcs-addin/wiki/Split-Files" + End If + End If + End If + End If + + End Select + +End Sub + + '--------------------------------------------------------------------------------------- ' Procedure : cmdAddOtherTableData_Click ' Author : Adam Waller