Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions access-add-in/source/modules/AddInConfiguration.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions access-add-in/source/modules/_config_Application.bas
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
' <use>base/ApplicationHandler_AppFile.cls</use>
' <use>base/modErrorHandler.bas</use>
' <use>_codelib/addins/shared/AccUnitConfiguration.cls</use>
' <use>_codelib/addins/shared/AddInConfiguration.cls</use>
'</codelib>
'---------------------------------------------------------------------------------------
'
Expand All @@ -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

'---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -110,6 +114,15 @@ End Sub
'
'End Sub

' Sets the database property AddInPrepareProcedure manually (run with F5 in the VBE)
Private Sub SetAddInPrepareProcedure()
With New AddInConfiguration
.LoadFromCurrentFile
.PrepareProcedure = ADDIN_PREPARE_PROCEDURE
.SaveToCurrentFile
End With
End Sub

Public Sub PrepareForVCS()
If DaoTools.TableDefExists("ACLib_ConfigTable") Then
Application.CurrentDb.TableDefs.Delete "ACLib_ConfigTable"
Expand Down