Using Object Variable

D

D Collins

Hello,

I need to capture the value of an option group on a form
that the user had initially chosen and then allow the
user to re-open the form with that option being
repopulated with their initial choice. Someone had told
me to use an object variable to retain the value, but I'm
having a little difficulty. Here's what I have:

ActiveDocument.Variables("MyVariable"), Value:=? I don't
know what to put here. I know I need to capture which of
the 4 choices in the option group they had chosen. Do I
use the name of the frame? Me.fraOptions.value?

Then, when the form initializes, I need to pass back the
value of the variable to the option group.

Thanks for your help.
D.
 
D

Doug Robbins - Word MVP

Put the option buttons inside a frame (which in the following code snippet
was called FramePresentation and use the following to assign a value to the
variable according to the button which has been selected.

For i = 1 To 5
Set acontrol = FramePresentation.Controls(i - 1)
If acontrol.Value = True Then
ActiveDocument.Variables("vPresentation").Value = i
acontrol.Value = False
End If
Next i

On reloading the form, use

i = ActiveDocument.Variables("vPresentation").Value
Set acontrol = FramePresentation.Controls(i - 1)
acontrol.Value = True

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top