Form Fields & UserForms Interactions HeLp!

B

Bugs

Great Forums for everthing Office but sometimes there is a lot of reading
required when you want to do something that seems simple and to no avail!

Here is the issue:

Our firm uses templates to create Functional Analsys Documents. The first
two pages of the FA Doc have on them two types of form fields. (Hopefully I
got all the terminology correct as I am a newbie to this type of
programming.)

Ones that can be edited by the user and ones that can get updated by
refrence when pressing the <F9> function key from within the field.

I wanted to simplify this by creating an optional user form that can be
called up through a Custom Menu. I have manage to do so but I'm running in to
updating the text fields in the user form correctly. The first time I use the
user form the defaulted values from the form fields get displayed in the user
form correctly. I used the following code when initailizing the user form;

Private Sub UserForm_Initialize()
With UserForm1
.TextBox2.Text = ActiveDocument.FormFields("Text2").Result
.TextBox1.Text = ActiveDocument.FormFields("Text1").Result
.TextBox3.Text = ActiveDocument.FormFields("Text6").Result
.TextBox4.Text = ActiveDocument.FormFields("Text4").Result
.TextBox5.Text = ActiveDocument.FormFields("Text3").Result
.TextBox6.Text = ActiveDocument.FormFields("Text5").Result
End With
End Sub

Which I obtained through reading in this forum.

I attached the follwoing code to a command button that update the form
fields without killing them ( I had some trouble keeping the form fields in
tact until once again you forum came to the rescue);

Private Sub CommandButton1_Click()
With ActiveDocument
.FormFields("Text2").Result = TextBox2
.FormFields("Text1").Result = TextBox1
.FormFields("Text6").Result = TextBox3
.FormFields("Text4").Result = TextBox4
.FormFields("Text3").Result = TextBox5
.FormFields("Text5").Result = TextBox6
End With
UserForm1.Hide
End Sub

All runs A-Ok until I change the value on the actual FA Document by clicking
on the form field then calling up the user form through the custom menu.

The values in the user form recall the previous values that I entered the
last time I used the user form. It's as if the user form has a buffer that
doesn't get reloaded after the first time the user form is called up.

How can I have the user form reflect the changes of the FA Doc fields No
mater how menay time the user form is called up?

I want to be able to edit these field from either the FA Doc form fields or
the new user form but alway displaying the correct values!

I have done quite a bit of reading that my eyes a bugging out and can't
hurdle this one yet!

HeLp!
 
C

Charles Kenyon

If you have your form protected for forms and have the field property
checked to calculate on exit, you don't need the F9 key. That is in the
online form, not the userform.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
H

Helmut Weber

Hi Bugs,

i'm no good at userforms,
but to me it seems that Initialize isn't the right event.
Try putting your code in UserForm_Activate()

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
B

Bugs

This did the trick!

Thanks Helmut now I can clean up the user form and wrap up this part of the
custom menu finctionality.
 
B

Bugs

Charles,

The fields that are being used to update are reference fields which are
based on values from Text Form Fields. These Text Form Fields have the
Fill-In Enable option checked so that the user can fill them in directly with
out using the user form.

The reference fields point to these fields but require for the user to
manually update them. It would be nice if I could come up with a macro that I
can add to my custom menu that will automatically update these type of fields
but that will be for later on as I need to complete the user form field
functionality.

I don't think I can protect the FA Document because it may cause other
problems with footers and headers that are currently being used but then
again I'm new to all of this so if you can detail a solution I can follow
through!

I appreciate your input regardless!
--
Thanks,
Bugs


Charles Kenyon said:
If you have your form protected for forms and have the field property
checked to calculate on exit, you don't need the F9 key. That is in the
online form, not the userform.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

No!

If you are using a protected form and if the source fields are set to
calculate on exit, the REF fields based on the form fields will update.
http://gregmaxey.mvps.org/Repeating_Data.htm

If this is the sole purpose of your UserForm, you are reinventing the wheel.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Bugs said:
Charles,

The fields that are being used to update are reference fields which are
based on values from Text Form Fields. These Text Form Fields have the
Fill-In Enable option checked so that the user can fill them in directly
with
out using the user form.

The reference fields point to these fields but require for the user to
manually update them. It would be nice if I could come up with a macro
that I
can add to my custom menu that will automatically update these type of
fields
but that will be for later on as I need to complete the user form field
functionality.

I don't think I can protect the FA Document because it may cause other
problems with footers and headers that are currently being used but then
again I'm new to all of this so if you can detail a solution I can follow
through!

I appreciate your input regardless!
 

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