Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
wendy
 
Posts: n/a
Default recreate a deleted formfield

Hi,
I am trying to create a template based on a number of user forms that
automatically fill in formfields, so that the resulting document is properly
formatted with all the required information. On the first user form, I ask
for (1) species common name, (2) whether there is a population name (Y/N),
(3) if so what it is, and (4) latin name. Then click OK and move onto the
next user form. I have it set up so that if the population question is
answered 'no', those formfields are deleted.

The problem is that on the next user form I have a back button, so that if a
user wanted to change information on the first user form they could go back.
But, in testing this, if I want to change the answer to the population
question to 'yes', and have the population name entered into its formfields,
the formfield has been deleted and I get an error message.

How do I incorporate the appropriate code, so that if the answer is 'No' the
field is deleted, but if the answer is then changed to 'yes' the formfield is
recreated and filled in??? The code I have so far is pasted below. BTW -
I'm pretty new to all this programming stuff, and to be honest, find it
horrifically confusing :0)

Thanks in advance for any help!

Private Sub OK3_Click()
pToggleProtectDoc

vCommonName = UserForm3.txtCommonName.Text
vPopulation = UserForm3.txtPopulation.Text
vScientificName = UserForm3.txtScientificName.Text

ActiveDocument.FormFields("bkCommonName1").Result = vCommonName
ActiveDocument.FormFields("bkCommonName2").Result = vCommonName
ActiveDocument.FormFields("bkCommonName3").Result = vCommonName
ActiveDocument.FormFields("bkCommonName4").Result = vCommonName

If UserForm3.optYes.Value = True Then
ActiveDocument.FormFields("bkPopulation1").Result = vPopulation
ActiveDocument.FormFields("bkPopulation2").Result = vPopulation
ActiveDocument.FormFields("bkPopulation3").Result = vPopulation
Else
ActiveDocument.FormFields("bkPopulation1").Delete
ActiveDocument.FormFields("bkPopulation2").Delete
ActiveDocument.FormFields("bkPopulation3").Delete
End If

ActiveDocument.FormFields("bkScientificName1").Res ult = vScientificName
ActiveDocument.FormFields("bkScientificName2").Res ult = vScientificName
ActiveDocument.FormFields("bkScientificName3").Res ult = vScientificName

pToggleProtectDoc

UserForm3.Hide
UserForm4.Show
End Sub


 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Spell Check Macro to work Tom Hyland Microsoft Word Help 8 January 14th 05 06:45 PM
I accidently deleted winword.exe from my computer. Now I can't o. Erica Microsoft Word Help 1 January 13th 05 06:38 PM
I deleted winword.exe from my computer. Now I can't open a word d Erica Microsoft Word Help 1 January 13th 05 04:07 PM
Is there vba script or reference fields that will recreate a catal Jeanne Moos Mailmerge 1 December 17th 04 10:20 AM
Microsoft word files are getting deleted automatically from the c. Mandar Microsoft Word Help 0 December 3rd 04 09:55 AM


All times are GMT +1. The time now is 07:57 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"