Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #46  
Old 12-22-2016, 04:30 PM
Father Father is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
There are fairly simple ways of hiding tables in Word, but not if they have formfields. An alternative for a table that has formfields might be to have the table on display but the formfields within it locked so they can only be accessed if whatever condition you select from the dropdown has the appropriate answer selected.
I like the idea of hiding information not used more for the fact that it gives a clean appearance. If it's not needed or used I'd rather it just not be there.

So... if it has any kind of form fields the table cannot be hidden? That's a bummer.
Option B... separate forms with and without the unneeded information. :/
Reply With Quote
  #47  
Old 12-22-2016, 05:14 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,666
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Quote:
Originally Posted by Father View Post
Option B... separate forms with and without the unneeded information. :/
Yes, you could do that, too.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #48  
Old 12-22-2016, 07:46 PM
Father Father is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Unless you only ever want to modify row 3 in table 2, you really should be using
.Tables(lTbl).Cell(lRow, 2).Range
That's because lTbl tells Word which table to modify and lRow tells Word which row in that table you're working with. If you're working on table 2, that's what lRow will contain and, if you're working on row 3, that's what lRow will contain. Note that it's lRow, not Row.
I'm attaching an updated version.
Disregard the content control parts.

2 issues

(1) In the macro I added OtherLocation for try to get block 4. dropdown option "Other" to behave like the dropdowns for 9a and 9b.

When I try to run this I get a compile error / syntax error.
It highlights With .Tables(lTbl).Cell(lRow, 3).Range.FormFields(1). I assume this means that either the table, cell, and/or row are not the right one(s) or do I need a different GetTblRow macro to run OtherLocation?

This is why I was asking about how to identify the table, row, and cell.

(2) When you use the "other" option that allows you to enter an additional choice it moves the "other" option in the dropdown from the top to the bottom. If you create 6 additional rows all using the "other" option it pushes the "other" option out of the menu altogether. Is there a way to keep "other" at the top of the drop down so it doesn't get pushed out? I left the additional rows created in place so you can see what I'm referring to.
Attached Files
File Type: docx EXPLOSIVE OPERATIONS DEPARTMENT.docx (37.0 KB, 1 views)
Reply With Quote
  #49  
Old 12-22-2016, 08:42 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,666
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Had you simply copied tables 9a & 9b, plus the updated code from the document in my last attachment (or if you'd stuck with that document and changed whatever other details might need changing), everything would have worked fine. Part of the editing I did entailed renaming some of the formfields & calculation fields so they would work properly with what you're trying to do.

As for the 'other' option, that is necessarily the last row because of the way the coding works. And, once you reach the limit of 25 entries in the dropdown, the 'other' option disappears - since it would no longer be valid. It might be advisable to tell your users that, if they're likely to need multiple rows with 'other' options, they add the necessary rows before choosing 'other'. That way, subsequent rows won't be pre-populated with the results of 'other' options from previous rows.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #50  
Old 12-22-2016, 09:52 PM
Father Father is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Had you simply copied tables 9a & 9b, plus the updated code from the document in my last attachment (or if you'd stuck with that document and changed whatever other details might need changing), everything would have worked fine. Part of the editing I did entailed renaming some of the formfields & calculation fields so they would work properly with what you're trying to do.

As for the 'other' option, that is necessarily the last row because of the way the coding works. And, once you reach the limit of 25 entries in the dropdown, the 'other' option disappears - since it would no longer be valid. It might be advisable to tell your users that, if they're likely to need multiple rows with 'other' options, they add the necessary rows before choosing 'other'. That way, subsequent rows won't be pre-populated with the results of 'other' options from previous rows.
I'll give that a shot. Thanks.
Reply With Quote
  #51  
Old 12-23-2016, 03:27 PM
Father Father is offline Windows 7 32bit Office 2013
Novice
 
Join Date: Nov 2016
Posts: 29
Father is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Had you simply copied tables 9a & 9b, plus the updated code from the document in my last attachment (or if you'd stuck with that document and changed whatever other details might need changing), everything would have worked fine. Part of the editing I did entailed renaming some of the formfields & calculation fields so they would work properly with what you're trying to do.
If you're referring to the attachment from this post, when I use it as is without changing the macro it has a runtime error '5941' when I try to apply it to the location dropdown. In the Drop-Down Form Field Options I set GetTblRow on Entry and OtherMunitions on Exit.

I thought maybe it was because that top table had merged cells but I re-did it without using merged cells and it still has the error.
Reply With Quote
  #52  
Old 12-23-2016, 07:52 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,666
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

The attachment to post #39 (http://www.msofficeforums.com/word-v...tml#post108097) works fine as is, but you can't simply take the existing OtherMunitions macro, which is designed for Tables 9a & 9b, and expect it to work in an entirely different situation. The existing GetTblRow macro won't cause problems, though, as it's only gathering data. Even so, it's not needed just for inputting another location in your first table.

Try the attached update. Note the addition of an OtherLocation macro.
Attached Files
File Type: docm EXPLOSIVE OPERATIONS DEPARTMENT.docm (47.0 KB, 2 views)
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Tags
calculating values, expanding table, form fields

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to keep formatted form fields after mail merge or replace text with formatted form fields jer85 Word VBA 2 04-05-2015 10:00 PM
Tables with form fields step10 Word 18 11-12-2013 02:27 PM
Enable editing in expanding fields marweste Word 11 10-21-2013 07:41 AM
How to prevent Tables from expanding HappyFingers Word 1 11-29-2010 01:54 PM
Calculating Form Fields in Microsoft Word wubba80 Word 1 06-25-2010 12:42 AM


All times are GMT -7. The time now is 08:28 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft