Skip to content

Commit

Permalink
Reset error break mode after loading options
Browse files Browse the repository at this point in the history
The ability to break and debug VBA errors is dependent on an option value that is saved with each project. The on error directive should be reset after loading the project options to ensure that we can successfully break on errors.
  • Loading branch information
joyfullservice committed Nov 27, 2023
1 parent e2989d2 commit 7a4a44f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Version Control.accda.src/modules/clsLog.cls
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Option Explicit
Public PadLength As Integer
Public ErrorLevel As eErrorLevel
Public OperationType As eOperationType
Public SourcePath As String

' Set this to true when logging an operation such as an export or build
' then set back to false after writing the log file. This affects
Expand Down Expand Up @@ -308,7 +309,7 @@ Public Property Get LogFilePath() As String
Case eotMerge: strFile = "Merge.log"
Case Else: strFile = "Other.log"
End Select
LogFilePath = FSO.BuildPath(Options.GetExportFolder, strFile)
LogFilePath = FSO.BuildPath(Me.SourcePath, strFile)
End Property


Expand Down
24 changes: 24 additions & 0 deletions Version Control.accda.src/modules/modImportExport.bas
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ Public Sub ExportSource(blnFullExport As Boolean, Optional intFilter As eContain
Options.LoadProjectOptions
Log.Clear
Log.OperationType = eotExport
Log.SourcePath = Options.GetExportFolder
Log.Active = True
Perf.StartTiming

' Check error handling mode after loading project options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' If options (or VCS version) have changed, a full export will be required
If (VCSIndex.OptionsHash <> Options.GetHash) Then blnFullExport = True

Expand Down Expand Up @@ -313,9 +317,13 @@ Public Sub ExportSingleObject(objItem As AccessObject, Optional frmMain As Form_
Options.LoadProjectOptions
Log.Clear
Log.OperationType = eotExport
Log.SourcePath = Options.GetExportFolder
Log.Active = True
Perf.StartTiming

' Check error handling mode after loading project options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' Display heading
With Log
.Spacer
Expand Down Expand Up @@ -482,9 +490,13 @@ Public Sub ExportMultipleObjects(objItems As Dictionary, Optional bolForceClose
Options.LoadProjectOptions
Log.Clear
Log.OperationType = eotExport
Log.SourcePath = Options.GetExportFolder
Log.Active = True
Perf.StartTiming

' Check error handling mode after loading project options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' Display heading
With Log
.Spacer
Expand Down Expand Up @@ -736,10 +748,13 @@ Public Sub Build(strSourceFolder As String, blnFullBuild As Boolean, _
End If
End If

' Load options from project
Set Options = Nothing
Options.LoadOptionsFromFile StripSlash(strSourceFolder) & PathSep & "vcs-options.json"
' Override the export folder when exporting to an alternate path.
If Len(strAlternatePath) Then Options.ExportFolder = strSourceFolder
' Update VBA debug mode after loading options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' Build original file name for database
If blnFullBuild Then
Expand Down Expand Up @@ -771,6 +786,7 @@ Public Sub Build(strSourceFolder As String, blnFullBuild As Boolean, _
' Start log and performance timers
Log.Clear
Log.OperationType = IIf(blnFullBuild, eotBuild, eotMerge)
Log.SourcePath = strSourceFolder
Log.Active = True
Perf.StartTiming

Expand Down Expand Up @@ -1120,9 +1136,13 @@ Public Sub LoadSingleObject(cComponentClass As IDbComponent, strName As String,
Options.LoadProjectOptions
Log.Clear
Log.OperationType = eotMerge
Log.SourcePath = Options.GetExportFolder
Log.Active = True
Perf.StartTiming

' Check error handling mode after loading project options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' Display heading
With Log
.Spacer
Expand Down Expand Up @@ -1235,9 +1255,13 @@ Public Sub MergeAllSource()
Options.LoadProjectOptions
Log.Clear
Log.OperationType = eotMerge
Log.SourcePath = Options.GetExportFolder
Log.Active = True
Perf.StartTiming

' Check error handling mode after loading project options
If DebugMode(True) Then On Error GoTo 0 Else On Error Resume Next

' Display heading
With Log
.Spacer
Expand Down

0 comments on commit 7a4a44f

Please sign in to comment.