I have a userForm (mappingGuide) that allows the user to select smartyTag from a list of more convenient names.
I have a second user form (conditionalBuilder) that I would call this userForm by double-clicking the text box so that the user can find which smartyTag to apply (in case they don't know).
So the logic is:
- open conditionalBuilder
- double-click the Field field
- mappingGuide opens
- select smartytag from the list.
- enter smartytag value in the text field of the field in the conditional buffer
- unload mappingGuide
The problem that I encounter in fulfilling this requirement is that when loading the forms themselves, I cannot find a way to set the text of the text field fieldName of the loaded instance of conditionalBuilder (see the last block of code below). I searched around but can't understand.
Here is the relevant code:
conditionalBuilder is loaded from the user interface ribbon
Sub RunCode(ByVal Control As IRibbonControl)
Select Case Control.ID
Case Is = "mapper": LoadMappingGuide
Case Is = "conditional": LoadConditionalBuilder
End Select
End Sub
Sub LoadConditionalBuilder()
Dim conditionalForm As New conditionalBuilder
conditionalForm.Show False
End Sub
double-click the fieldName event, then load mapGuide
Private Sub fieldName_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.hide
Dim pickField As New mappingGuide
pickField.Show False
End Sub
smartTag listbox click event then tries to put the selection in fieldName (or the choice if the form is not loaded)
Private Sub smartTagList_Click()
If smartTagList.ListIndex > -1 And smartTagList.Selected(smartTagList.ListIndex) Then
Dim smartyTag As String
smartyTag = smartTagList.List(smartTagList.ListIndex, 2)
If isUserFormLoaded(conditionalBuilder.Name) Then
'*** ---> below is my issue how to reference instance of form
conditionalBuilder.fieldName.Text = smartyTag
conditionalBuilder.Show
Else
Selection.Range.Text = smartyTag
End If
End If
Unload Me
End Sub
If there is a more efficient setting, it will also be very useful. I have separate forms because there are several levels that a user can create with tags.
source
share