Electronic Form Desperate help needed

S

Shazza

Hi I have created a form where all fields MUST be filled in. Unfortunately
people ignore my requests and just bypass them filling in what they want. I
have recently added a bit of code into a macro that was supposed to stop this
from happening. Unfortunately it does not work. I have drop down fields
that can be bypassed and if people use their mouse to click on a another
field then they can also bypass them.

I need every single field filled in as it is compulsory information that is
being requested. How can I stop them from just leaving the field blank not
only from a text field but from a drop down list box too????

Please please help me. I am desperate to get this sorted and have tried
everything I know.
 
G

Graham Mayor

You haven't indicated which code you used, however the code at
http://www.gmayor.com/formfieldmacros.htm should do the trick, provided you
can overcome the issue of getting the users to allow the macros to run.

By using the on-entry macros in all fields (there is a macro there to
facilitate that) selecting another field with the mouse would show an error
when a required field was not completed and return the cursor to the
unfilled field.

The issue with dropdown fields is a little more complicated as you would be
testing for a value in the field, and a dropdown field by its very nature
would always have a value. Unless there is some way to cross reference that
value for accuracy the macro will assume the default value is correct. I
suppose that you could insert a couple of spaces as the default value in the
drop down and check for their presence to indicate the content has not been
changed. Frankly I wouldn't bother. Just use the on-entry macro on that
field and the on-exit macros on the text form fields.

Much the same problem arises with checkboxes in which both checked and
unchecked states are legitimate. If the user chooses not to check a box the
macro would have no way of knowing whether that was a correct choice.


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

Shazza

Hi this is the same code as i tried before and works a treat if i use the
keyboard but as soon as i click on another field with a mouse it stops
working.

Is there any other way of doing it rather than a macro or is this the only
way??
 
G

Graham Mayor

It shouldn't stop working if the field you click on has the on-entry macro.
Thus if you add the on-entry macro to all fields (use the other macro)
whichever field you select will prompt the warning and return you to the
field you left. It is of course necessary to start with the cursor position
saved in an unfilled field.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

There are circumstances where it is possible to stop without filling in all
the fields. You can get around this with some more macros which will prevent
the document from being saved or printed when text fields are empty, within
the limits of what macros will permit - something along the lines of:.

Public Clear As Boolean
Sub FileSave()
TestField
If Clear = True Then
ActiveDocument.Save
End If
End Sub

Sub FileSaveAs()
TestField
If Clear = True Then
Dialogs(wdDialogFileSaveAs).Show
End If
End Sub

Sub FilePrint()
TestField
If Clear = True Then
Dialogs(wdDialogFilePrint).Show
End If
End Sub

Sub FilePrintDefault()
TestField
If Clear = True Then
ActiveDocument.PrintOut
End If
End Sub

Private Function TestField()
For i = 1 To ActiveDocument.FormFields.Count
If ActiveDocument.FormFields(i).Type = wdFieldFormTextInput Then
If ActiveDocument.FormFields(i).Result = "" Then
MsgBox "You must complete all the fields", vbCritical, "Error"
ActiveDocument.FormFields(i).Select
Clear = False
Exit Function
End If
End If
Next i
Clear = True
End Function

You could also provide the users with more explicit instructions eg

Sub AutoNew()
MsgBox "Complete all the fields and" & vbCr & _
"use the TAB key to move" & vbCr & _
"between fields."
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - 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