Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2005

Tip: Looking for answers? Try searching our database.

UserForm on Update - Add to Table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wendy D - 18 Aug 2005 18:09 GMT
I am wondering if it is possible to have a user form run when a document is
updated only (not on initial creation) and have the information (that the
user enters) create a new row in a table (each time it is updated)?  Make
Sense?

Thank You.
Wendy
Doug Robbins - 18 Aug 2005 18:25 GMT
The userform could be made to display by the use of an autoopen() macro in
the template from which the document was created.  I am not really sure what
you mean by the rest of your question.  Do you want the user to enter the
information into the userform and then a row be added to a table and that
information be inserted into that row?

Seems a round-about way of doing something.

Signature

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

>I am wondering if it is possible to have a user form run when a document is
> updated only (not on initial creation) and have the information (that the
[quoted text clipped - 3 lines]
> Thank You.
> Wendy
Wendy D - 18 Aug 2005 18:36 GMT
"Doug Robbins" wrote:  "Do you want the user to enter the information into
the userform and then a row be added to a table and that information be
inserted into that row?"

Yes that is what I want to do.  After initial creation, when ever the
document is changed, it needs an "audit history" identifying the date of
change, reason for change, and new version number.  Currently, I have a table
created for this information.  If possible, I'd like to utilize a userform
for this purpose rather than have the user remember to update the table
manually.

Thank You.
Wendy

> The userform could be made to display by the use of an autoopen() macro in
> the template from which the document was created.  I am not really sure what
[quoted text clipped - 11 lines]
> > Thank You.
> > Wendy
Doug Robbins - 18 Aug 2005 21:11 GMT
OK, then you will need code in a command button on the form to add a row to
the table and then populate the cells in that row with the information
entered into the form.

Something like

Dim arow as row
Set arow=ActiveDocument.Tables(n).Rows.Add
With arow
   .Cells(1).Range.Text = TextBox1
   .Cells(2).Range.Text = TextBox2

   .Cells(n-1).Range.Text = TextBoxn-1
   .Cells(n).Range.Text = TextBoxn
End With

Signature

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

> "Doug Robbins" wrote:  "Do you want the user to enter the information into
> the userform and then a row be added to a table and that information be
[quoted text clipped - 31 lines]
>> > Thank You.
>> > Wendy
Wendy D - 18 Aug 2005 22:11 GMT
Doug - you're good!  

It's very close.  I get the userform to open when the document opens.  And
it seems to be trying to create the row, but I got an error.

"Run-time error '5941':  The requested member of the collection does not
exist."

Below is the code in the command button.  Can you see if I interpreted your
instructions right?

Private Sub CommandButton1_Click()

Dim arow As Row
Set arow = ActiveDocument.Tables(1).Rows.Add
With arow
   .Cells(1).Range.Text = TextBox2
   .Cells(2).Range.Text = TextBox3
   .Cells(3).Range.Text = TextBox1

   .Cells(n - 1).Range.Text = TextBoxn - 1  *DEBUG HIGHLIGHTS THIS LINE*
   .Cells(n).Range.Text = TextBoxn
End With
   
UserForm2.Hide

End Sub

> OK, then you will need code in a command button on the form to add a row to
> the table and then populate the cells in that row with the information
[quoted text clipped - 47 lines]
> >> > Thank You.
> >> > Wendy
Doug Robbins - 19 Aug 2005 05:03 GMT
I just used the index n because I did not know how many pieces of data you
had to deal with.

If it was only three, stop after the Cells(3).  If it's 4, add another line
Cells(4) etc.

Signature

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

> Doug - you're good!
>
[quoted text clipped - 86 lines]
>> >> > Thank You.
>> >> > Wendy
Wendy D - 19 Aug 2005 15:43 GMT
Doug,

I'm sorry, but I don't understand you.  I DO only have 3 cells/fields to
fill in.  How do I do the last section?

> > With arow
> >    .Cells(1).Range.Text = TextBox2
[quoted text clipped - 4 lines]
> >    .Cells(n).Range.Text = TextBoxn
> > End With

Thank You.
Wendy

> I just used the index n because I did not know how many pieces of data you
> had to deal with.
[quoted text clipped - 92 lines]
> >> >> > Thank You.
> >> >> > Wendy
Doug Robbins - 19 Aug 2005 18:21 GMT
Dim arow as row
Set arow=ActiveDocument.Tables(n).Rows.Add
With arow
   .Cells(1).Range.Text = TextBox2
   .Cells(2).Range.Text = TextBox3
   .Cells(3).Range.Text = TextBox1
End With

Didn't you do any mathematics at school?<g>
Signature

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

> Doug,
>
[quoted text clipped - 125 lines]
>> >> >> > Thank You.
>> >> >> > Wendy
Wendy D - 19 Aug 2005 19:10 GMT
Ooohhh...

So when you wrote:

.Cells(n - 1).Range.Text = TextBoxn - 1
.Cells(n).Range.Text = TextBoxn

You were just saying "continue for as many cells/fields as you have data
for"!!

Thanks Again!
Wendy

> Dim arow as row
> Set arow=ActiveDocument.Tables(n).Rows.Add
[quoted text clipped - 134 lines]
> >> >> >> > Thank You.
> >> >> >> > Wendy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.