Empty Formfield Contents

S

spunkymuffmonkey

Hi all,

I need some help with testing for empty formfields.

I'm developing a protected form, this protected form contains a macro for
adding or removing rows from a table.

This macro fires a userform with which users can choose how many rows they
wish to add, this userform also contains a picklist for users to choose which
row they wish to delete from the same table.

The picklist reads the contents of the formfield within the first cell of
each row within the table and returns the contents (minus the Chr(13)) into a
picklist within the userform.

Pressing a button on my userform then matches the picklist option to the
formfield content and deletes this row from the document.

My problem is that I want to be able to detect and delete a blank row,
although I have figured out that I could put a default value in each
formfield when it's added, such as "Enter Name" or a blank space like " "
and test against that value I thought I would try to do it properly.

I just cannot seem to be able to correctly test against a formfield blank
value and any advice or assistance would be gratefully received.

Thanks for looking.
 
M

macropod

Hi spunkymuffmonkey,

For the first formfield in a document:
If Trim(ActiveDocument.FormFields(1).Result) = "" Then

For a formfield with the default blanks, you don't even need the Trim - but you do if the user has replaced the default blanks with
one or more spaces.
 
S

spunkymuffmonkey

Many many thanks indeed for the prompt response and help.

macropod said:
Hi spunkymuffmonkey,

For the first formfield in a document:
If Trim(ActiveDocument.FormFields(1).Result) = "" Then

For a formfield with the default blanks, you don't even need the Trim - but you do if the user has replaced the default blanks with
one or more spaces.

--
Cheers
macropod
[Microsoft MVP - Word]


spunkymuffmonkey said:
Hi all,

I need some help with testing for empty formfields.

I'm developing a protected form, this protected form contains a macro for
adding or removing rows from a table.

This macro fires a userform with which users can choose how many rows they
wish to add, this userform also contains a picklist for users to choose which
row they wish to delete from the same table.

The picklist reads the contents of the formfield within the first cell of
each row within the table and returns the contents (minus the Chr(13)) into a
picklist within the userform.

Pressing a button on my userform then matches the picklist option to the
formfield content and deletes this row from the document.

My problem is that I want to be able to detect and delete a blank row,
although I have figured out that I could put a default value in each
formfield when it's added, such as "Enter Name" or a blank space like " "
and test against that value I thought I would try to do it properly.

I just cannot seem to be able to correctly test against a formfield blank
value and any advice or assistance would be gratefully received.

Thanks for looking.

.
 

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