PDA

View Full Version : Form Field Validation w/ Mail Merge...



sandonn
05-16-2007, 12:57 PM
I need help using Form Field Validation w/ Mail Merge...

I need a field to be manually filled in by the user.
I found a script that does form field validation.
The problem is that I can't lock the Form because I am also using Mail Merge.
When I lock the form, the validation works but the mail merge no longer works.

Is there a way to do this???

Thanks


This is the script I found for the validation...

Private mstrFF As String

Public Sub AOnExit()
With GetCurrentFF
If Len(.Result) = 0 Then
MsgBox "You can't leave field: " & .Name & " blank"
mstrFF = GetCurrentFF.Name
End If
End With
End Sub

Public Sub AOnEntry()
Dim strCurrentFF As String

If LenB(mstrFF) > 0 Then
ActiveDocument.FormFields(mstrFF).Select
mstrFF = vbNullString
End If
End Sub


Private Function GetCurrentFF() As Word.FormField
With Selection
If .FormFields.Count = 1 Then

' CheckBox or DropDown
Set GetCurrentFF = .FormFields(1)

ElseIf .FormFields.Count = 0 And .Bookmarks.Count > 0 Then
Set GetCurrentFF = ActiveDocument.FormFields _
(.Bookmarks(.Bookmarks.Count).Name)
End If
End With
End Function

mdmackillop
05-16-2007, 01:16 PM
Hi Sandonn,
Welcome to VBAX
You can split the document into sections (continuous) and FormProtect only that section containing your formfield.

mdmackillop
05-16-2007, 01:28 PM
BTW,
When you post code, select it and click the VBA button to format the code as shown. It makes it more readable.

sandonn
05-16-2007, 01:47 PM
Thanks mdmackillop...

When you say split the screen are you referring to the "Split" from the "Window" menu.
That doesn't actually create 2 frames, only lets you view 2 different parts.

Maybe I'm missing something.

Thanks

mdmackillop
05-16-2007, 01:57 PM
Here's a sample

sandonn
05-17-2007, 08:04 AM
I wasn't able to view your attachment. I am getting the message "To view attachments your post count must be 0 or greater. Your post count is 0 momentarily."

Anyway, I did something similar to what you are suggesting and it didn't work.
In Word I went to Insert-->Break-->Section Break Types-->Continuous Break.
I created 2 breaks. One before and after the form I wanted to validate/protect.
Then I went to Tools-->Protect Document-->Forms, and also selected Sections.

That allowed me to lock just the form field, but still allow me to modify the other fields of the document.

Then problem I had was that the mail mergre didn't work.
I was able to modify all fields except for the one I protected, but I guess the mail merge still saw the document as being locked.
I think I might be S.O.L unless you have any other ideas...

Thanks

sandonn
05-17-2007, 08:08 AM
How about this.
Is there a way w/ VB that I can create a pop-up window alerting the user to be sure they filled in the field.
Maybe have it activated when they try to save the document.

Thanks