Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
oj oj is offline
external usenet poster
 
Posts: 1
Default word and forms: updating a table by adding more rows

Hello,

I have an ordering form that I created a while ago which I would
like to modify. In the form I have a table with columns for 'item
description', 'size', 'cost per unit', and 'quantity'. When the form
is protected users can fill in the descriptions and values. When
'quantity' and 'cost per unit' are filled in, a cell at the end of the
row automatically fills in with the subtotal. This table is fixed at
10 rows, and cell in another table automatically sums all the
subtotals together, adds in a predetermined amount of shipping and
handling charges and displays the result.
The question I have is: Is it possible to have the form open up
with two rows in the table (for filling in 'item description', 'size',
'cost per unit', and 'quantity'), and when the user fills in the
second row a third row appears (and if they fill in the third row, a
fourth row appears, etc.)? Could this happen and the total (in the
other table) be calculated as it is now?

Thanks.
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default word and forms: updating a table by adding more rows

' To add a new row to a table containing formfields in every column
' automatically on exit from the last cell in the present last row of the
table
Dim rownum As Integer, i As Integer
ActiveDocument.Unprotect
ActiveDocument.Tables(1).Rows.Add
rownum = ActiveDocument.Tables(1).Rows.Count
For i = 1 To ActiveDocument.Tables(1).Columns.Count
ActiveDocument.FormFields.Add _
Range:=ActiveDocument.Tables(1).Cell(rownum, i).Range,
Type:=wdFieldFormTextInput
Next i
ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(1).Rows.Count, _
ActiveDocument.Tables(1).Columns.Count).Range.Form Fields(1).ExitMacro =
"addrow"
ActiveDocument.Tables(1).Cell(ActiveDocument.Table s(1).Rows.Count,
1).Range.FormFields(1).Select
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

End Sub

In addition, you will probably need to incorporate the code from the article
"How to assign a Name to a FormField that doesn't already have a Name, using
VBA" at:

http://www.word.mvps.org/FAQs/Macros...ameToFmFld.htm

so that you can name the new formfields and thus be able to reference them
in assigning a formula to the last formfield in each row so that it will
display the total for that row and also in a formula that calculated the
total of all of the rows.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"oj" wrote in message
...
Hello,

I have an ordering form that I created a while ago which I would
like to modify. In the form I have a table with columns for 'item
description', 'size', 'cost per unit', and 'quantity'. When the form
is protected users can fill in the descriptions and values. When
'quantity' and 'cost per unit' are filled in, a cell at the end of the
row automatically fills in with the subtotal. This table is fixed at
10 rows, and cell in another table automatically sums all the
subtotals together, adds in a predetermined amount of shipping and
handling charges and displays the result.
The question I have is: Is it possible to have the form open up
with two rows in the table (for filling in 'item description', 'size',
'cost per unit', and 'quantity'), and when the user fills in the
second row a third row appears (and if they fill in the third row, a
fourth row appears, etc.)? Could this happen and the total (in the
other table) be calculated as it is now?

Thanks.



Reply
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
Stop adding rows to end of table olwenh Tables 3 August 10th 07 02:59 AM
Adding rows to a table Peter Guest Tables 2 November 25th 06 07:49 AM
Adding rows to a table Peter Guest New Users 3 November 22nd 06 08:01 PM
Why do rows in a table stack when adding a new row? Dottie in Asheville NC Tables 2 March 26th 06 11:59 PM
Adding multiple rows to a table in Word? Iron Mt Library Guy Microsoft Word Help 3 February 5th 05 12:08 AM


All times are GMT +1. The time now is 03:14 PM.

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

About Us

"It's about Microsoft Word"