I am using Allen Browne's brilliant code (http://allenbrowne.com/ser-35.html) to open several instances of a form on click event. I understand that new instances are read-only and I managed to record the data the user inputs, to keep a log, thanks to this post (Access 2007 / VBA - Multiple Instances of Form, Update controls on specific instance from Module).
I have several combo boxes on each form and would like to update/requery what is shown in one depending on user selection on other (for each form, not among forms). For ex, user choose component A on cmb1, cmb2 only shows possible failures of component A.
{me.Requery} will only and always requery the form in the Forms class (the one opened from the database window/nav pane, if any, not the instances on clnClient collection below). However, I can pass information with "Me" and retrieve values for the logging.
Using a slightly modified OpenAClient version from Allen Browne's with input from MajP (in this great thread https://www.tek-tips.com/viewthread.cfm?qid=1753790)
Public clnClient As New Collection
Public Function OpenAClient(FormName As String, Optional inputCaption As String = "") As Form_f_myForm
'Purpose: Open an independent instance of form f_myForm
On Error GoTo Err_OpenAClient
Dim frm As Form
'Open a new instance, show it, and set a caption.
Set frm = New Form_f_myForm
frm.Visible = True
frm.Caption = inputCaption
frm.Tag = FormName
'Append it to our collection.
clnClient.Add Item:=frm, Key:=FormName
Set OpenAClient = frm
Set frm = Nothing
Exit Function
Err_OpenAClient:
If Err.Number = 457 Then
MsgBox "A Form with this name already exists."
Else
MsgBox Err.Number & " " & Err.Description
End If
End Function
I have tried
Public ActiveForm As Form_f_myform
Set activeForm = OpenAClient("ExampleForm","Example caption")
or a simple
Set activeForm = clnClient.Item(2) 'just to test the second instance
and then use ActiveForm instead of "Me" and manipulate it that way, but it does not seem to work. Any ideas/help would be appreciated. Or ideas to tackle this in a different way. Thanks!
A bit of background. I am very new to VBA and Access, working on a database (Access Office365) for failure reporting. All failures have been assessed beforehand delivery to the user. The user will identify the specific component that is failing and fill the form accordingly (date, type of failure etc..). They will not change the table containing the pre-assessment. This is all fine and working. The issue is when adding the ability for the user to report multiple failures.