Skip to content

Commit

Permalink
Add change hook for options
Browse files Browse the repository at this point in the history
Used for special processing when certain options change.
  • Loading branch information
joyfullservice committed Nov 13, 2023
1 parent ff706a4 commit 07bc57c
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions Version Control.accda.src/forms/frmVCSOptions.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 07bc57c

Please sign in to comment.