From 50ed1f6ed94a8c4e5d2980330ff8d5830d3468bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20P=C3=B6tzl?= Date: Sun, 29 Nov 2026 21:38:38 +0100 Subject: [PATCH 1/2] Add setter for AddInPrepareProcedure database property --- .../source/modules/AddInConfiguration.cls | 31 +++++++++++++++++++ .../source/modules/_config_Application.bas | 14 +++++++++ 2 files changed, 45 insertions(+) diff --git a/access-add-in/source/modules/AddInConfiguration.cls b/access-add-in/source/modules/AddInConfiguration.cls index b0eebf6..a590629 100644 --- a/access-add-in/source/modules/AddInConfiguration.cls +++ b/access-add-in/source/modules/AddInConfiguration.cls @@ -31,6 +31,7 @@ Option Explicit ' Procedure run in the installed add-in file before it is used/compiled (e.g. to set references) Private Const DbPropertyNamePrepareProcedure As String = "AddInPrepareProcedure" +Private Const ErrNumberItemNotFound As Long = 3265 Private m_AppTitle As String Private m_Title As String @@ -249,6 +250,7 @@ Private Sub SaveDataToDatabase() Set db = CurrentDb SetDbProperty db, "AppTitle", m_AppTitle + SavePrepareProcedure db SetDocProperty db, "Title", m_Title SetDocProperty db, "Author", m_Author @@ -257,6 +259,35 @@ Private Sub SaveDataToDatabase() End Sub +' DAO cannot create a text property with an empty value, so an empty value removes the property +Private Sub SavePrepareProcedure(ByVal PropDb As DAO.Database) + + If Len(m_PrepareProcedure) > 0 Then + SetDbProperty PropDb, DbPropertyNamePrepareProcedure, m_PrepareProcedure + Else + RemoveDbProperty PropDb, DbPropertyNamePrepareProcedure + End If + +End Sub + +Private Sub RemoveDbProperty(ByVal PropDb As DAO.Database, ByVal PropertyName As String) + +On Error GoTo HandleErr + + PropDb.Properties.Delete PropertyName + +ExitHere: + Exit Sub + +HandleErr: + If Err.Number = ErrNumberItemNotFound Then + Resume ExitHere + End If + + Err.Raise Err.Number, "AddInConfiguration.RemoveDbProperty->" & Err.Source, Err.Description + +End Sub + Private Sub SetDbProperty(ByVal PropDb As DAO.Database, PropertyName As String, ByVal NewValue As Variant) On Error GoTo HandleErr diff --git a/access-add-in/source/modules/_config_Application.bas b/access-add-in/source/modules/_config_Application.bas index e64da0a..794d431 100644 --- a/access-add-in/source/modules/_config_Application.bas +++ b/access-add-in/source/modules/_config_Application.bas @@ -11,6 +11,7 @@ ' base/ApplicationHandler_AppFile.cls ' base/modErrorHandler.bas ' _codelib/addins/shared/AccUnitConfiguration.cls +' _codelib/addins/shared/AddInConfiguration.cls ' '--------------------------------------------------------------------------------------- ' @@ -29,6 +30,9 @@ Public Const ACCUNIT_DLL_FILE As String = "AccUnit.dll" Private Const APPLICATION_STARTFORMNAME As String = "AccUnitLoaderForm" +' Run by the add-in installer in the installed add-in file (sets the AccUnit.tlb reference) +Private Const ADDIN_PREPARE_PROCEDURE As String = "CheckAccUnitTypeLibFile" + Private m_Extensions As Object 'ApplicationHandler_ExtensionCollection '--------------------------------------------------------------------------------------- @@ -110,6 +114,16 @@ End Sub ' 'End Sub +' Sets the database property AddInPrepareProcedure manually (e.g. from the immediate window); +' an empty ProcedureName removes the property +Public Sub SetAddInPrepareProcedure(Optional ByVal ProcedureName As String = ADDIN_PREPARE_PROCEDURE) + With New AddInConfiguration + .LoadFromCurrentFile + .PrepareProcedure = ProcedureName + .SaveToCurrentFile + End With +End Sub + Public Sub PrepareForVCS() If DaoTools.TableDefExists("ACLib_ConfigTable") Then Application.CurrentDb.TableDefs.Delete "ACLib_ConfigTable" From ac318bb229dae032514462b6b4a4c0a2a89ee705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20P=C3=B6tzl?= Date: Sun, 29 Nov 2026 21:41:44 +0100 Subject: [PATCH 2/2] Make SetAddInPrepareProcedure private --- access-add-in/source/modules/_config_Application.bas | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/access-add-in/source/modules/_config_Application.bas b/access-add-in/source/modules/_config_Application.bas index 794d431..b369e42 100644 --- a/access-add-in/source/modules/_config_Application.bas +++ b/access-add-in/source/modules/_config_Application.bas @@ -114,12 +114,11 @@ End Sub ' 'End Sub -' Sets the database property AddInPrepareProcedure manually (e.g. from the immediate window); -' an empty ProcedureName removes the property -Public Sub SetAddInPrepareProcedure(Optional ByVal ProcedureName As String = ADDIN_PREPARE_PROCEDURE) +' Sets the database property AddInPrepareProcedure manually (run with F5 in the VBE) +Private Sub SetAddInPrepareProcedure() With New AddInConfiguration .LoadFromCurrentFile - .PrepareProcedure = ProcedureName + .PrepareProcedure = ADDIN_PREPARE_PROCEDURE .SaveToCurrentFile End With End Sub