Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
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 | |
|
|
![]() |
||||
Thread | Forum | |||
Getting Spell Check Macro to work | Microsoft Word Help | |||
I accidently deleted winword.exe from my computer. Now I can't o. | Microsoft Word Help | |||
I deleted winword.exe from my computer. Now I can't open a word d | Microsoft Word Help | |||
Is there vba script or reference fields that will recreate a catal | Mailmerge | |||
Microsoft word files are getting deleted automatically from the c. | Microsoft Word Help |