Opening a form in a library and retrieving a returned value

Standard method in library to open any form
See both the dialog and non dialog versions.
Code:
Public Function openForm(formName, Optional view As AcFormView = acNormal, Optional filterName, Optional whereCOndition, Optional datamode As AcFormOpenDataMode = acFormPropertySettings, Optional windowMode As AcWindowMode = acWindowNormal, Optional openArgs) As Access.Form
    DoCmd.openForm formName, view, filterName, whereCOndition, datamode, windowMode, openArgs
    Set openForm = Forms(formName)
End Function

Non dialog version

Code:
Public WithEvents FrmMonthYear As Access.Form
'****************************************************************************************************************************************************************
'-----------------------------------------------------------------------------------   No Dialog   -------------------------------------------------------------
'*****************************************************************************************************************************************************************
Private Sub cmdLibraryNoDialog_Click()
Set FrmMonthYear = calendarlibrary.OpenForm("MonthYearPicker_NoDialog")
FrmMonthYear.OnClose = "[Event Procedure]"
End Sub

Private Sub FrmMonthYear_Close()
  'Allows for OK / Cancel. Put a property in the class if the OK button was selected
If FrmMonthYear.ok_Selected Then 'custom property
   Me.txtMonth = FrmMonthYear.txtYearMonth
   Me.txtYear = FrmMonthYear.txtYearMonth
End If
End Sub


I added a property in the form to check if OK was selected.[/ICODE]
@MajP The not dialoge version works just fine.
Simple and very easy to re-use.
Seems that I was over-complicated my situation.

Million thanks for your help.
 
Will I be faced problems if I use the add-in located in a server, where all FEs can use it?
In principle, this should work - just as a frontend could theoretically be located in a network directory. However, I would not recommend this variant.
For example, it could be difficult to update the library if it is still accessible.
If you use the "add-in variant" as shown in #18, you can also just update the library without having to recreate the frontend.
 

Users who are viewing this thread

Back
Top Bottom