I have been scratching my head over this one for a day now!
I have a word 2007 document with 2 user forms, Form1 and Form2. Form2 is activated from Form1 and should let the user select a value from a listbox and have that value sent to a textbox Text1 in Form1.
I am doing this as follows:
in Form1 module
Expand|Select|Wrap|Line Numbers
- Public Sub SetCode(ByVal Code as String)
- Me.Field1.Value=Code
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub Button_Click()
- SelectedValue = Me.ListBox1.Column(0)
- Call Form1.SetCode(SelectedValue)
- Unload Me
- End Sub
While trying to resolve this I found that if I add a command button to Form1 that says
Expand|Select|Wrap|Line Numbers
- msgbox Form1.Field1.value
If I add a line that says
Expand|Select|Wrap|Line Numbers
- msgbox me.Field1.value
If I run a line from Form1 that says
Expand|Select|Wrap|Line Numbers
- me.Field1.value = Form1.Field1.value
I've tried refreshing and repainting Form1 and adding DoEvents and other methods of refreshing/updating the screen with no luck. It appears that when a variable is sent to a form1 field from form2, that variable can be found in form1.control but not me.control, and the value of me.control does not appear on form1 (even though me.name = form1 when checked.
I'm just about to bite the bullet and just put my big listbox on Form1 instead of its own form to resolve this but I'd be very grateful for any suggestions to fix/work around!