Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2010, 01:11 AM
chesspupil chesspupil is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2003
Novice
Form Field - Drop down selection causing auto text
 
Join Date: Apr 2006
Posts: 8
chesspupil
Send a message via MSN to chesspupil Send a message via Yahoo to chesspupil
Default Form Field - Drop down selection causing auto text

I do inspection work on submarines that must be documented. Each Boat has it own ID code that I would like to appear in another are of the form based on what boat I select from a Form filed drop down list.




Please see the attachment:

Block one I select a boat in the drop down. In block 2 I would like the first 5 numbers to automatically appear based on the selection in block 1. Currently they are in matching order but it is easy to mis-select the wrong 5 digit number if you are not careful or familiar with the layout.

I have no preference for how its done, just that it works...(VBA or Macro)
Attached Files
File Type: doc Misc Report Blank .doc (62.0 KB, 54 views)
Reply With Quote
  #2  
Old 05-07-2010, 02:29 PM
chesspupil chesspupil is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2003
Novice
Form Field - Drop down selection causing auto text
 
Join Date: Apr 2006
Posts: 8
chesspupil
Send a message via MSN to chesspupil Send a message via Yahoo to chesspupil
Default

The first sentences should read:

I hope you can help:

I do inspection work on submarines that must be documented. Each Boat has it own ID code that I would like to appear in another area of the form based on what boat I select from a Form filed drop down list.
Reply With Quote
  #3  
Old 05-07-2010, 05:06 PM
gmaxey gmaxey is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,204
gmaxey has a spectacular aura aboutgmaxey has a spectacular aura aboutgmaxey has a spectacular aura about
Default

Say your Dropdown is bookmarked "Name" and yoru text field for the Unit Identification Code is bookmarked "UIC." You need to set a macro to run on exit from the DD.

Sub NameDDOnExit()
Dim oFF As FormFields
Set oFF = ActiveDocument.FormFields
Select Case oFF("Name").Result
Case "TOPEKA"
oFF("UIC").Result = "12345"
Case "PASADENA"
oFF("UIC").Result = "54321"
Case "HELENA"
oFF("UIC").Result = "99999"
End Select
End Sub
Reply With Quote
  #4  
Old 05-07-2010, 10:31 PM
chesspupil chesspupil is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2003
Novice
Form Field - Drop down selection causing auto text
 
Join Date: Apr 2006
Posts: 8
chesspupil
Send a message via MSN to chesspupil Send a message via Yahoo to chesspupil
Default

Thank you very much for your help I got it to work perfectly. Can you help further?
This will help accuracy in our shop a great deal.

For a check box what would the commands look like?

For the VT/DIM box to be checked in block 10
the first form field in block 11 would say 1C
Reply With Quote
  #5  
Old 05-08-2010, 06:02 AM
gmaxey gmaxey is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,204
gmaxey has a spectacular aura aboutgmaxey has a spectacular aura aboutgmaxey has a spectacular aura about
Default

First let me say that I know how much submariners love to be inspected so perhaps I shouldn't do more to make it easier on your shop .

That said, I also know that submariners don't always appreciate what is best for them so:

The first thing you need to do is to assign meaningful bookmark names to your formfields. Continuing from the previous example, lets name the checkbox VT_DIM and the text field B11_1 (That is for block 11, field 1 and perhaps not so meaningful).

You could simply create another OnExit macro specifically for the checkbox, but if this is something you want to fully exploit then you should use a single OnExit macro. Something like this:

Sub FormFieldOnExit()
Dim oFF As FormFields
Set oFF = ActiveDocument.FormFields
Dim pName As String
pName = FieldID
Select Case pName
Case "Name"
Select Case oFF(pName).Result
Case "TOPEKA"
oFF("UIC").Result = "12345"
Case "PASADENA"
oFF("UIC").Result = "54321"
Case "HELENA"
oFF("UIC").Result = "99999"
End Select
Case "VT_DIM"
Select Case oFF("VT_DIM").CheckBox.Value
Case "True"
oFF("B11_1").Result = "1C"
Case Else
oFF("B11_1").Result = ""
End Select
End Select
End Sub
Function FieldID() As String
Dim pFldName As String
If Selection.FormFields.Count = 1 Then
pFldName = Selection.FormFields(1).Name
ElseIf Selection.FormFields.Count = 0 And Selection.Bookmarks.Count > 0 Then
pFldName = Selection.Bookmarks(Selection.Bookmarks.Count).Nam e
End If
FieldID = pFldName
End Function
Reply With Quote
  #6  
Old 05-08-2010, 02:59 PM
chesspupil chesspupil is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2003
Novice
Form Field - Drop down selection causing auto text
 
Join Date: Apr 2006
Posts: 8
chesspupil
Send a message via MSN to chesspupil Send a message via Yahoo to chesspupil
Default

Thank you for your help... I am about to step out to do another inspection. I do not inspect submariners often, but rather those that repair and replace corroded components...it is amazing what the saltwater does to steel once it is exposed by chipped paint.

I will let you know how the next upgrade goes... thank you for your help.
Reply With Quote
  #7  
Old 05-09-2010, 01:08 AM
chesspupil chesspupil is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2003
Novice
Form Field - Drop down selection causing auto text
 
Join Date: Apr 2006
Posts: 8
chesspupil
Send a message via MSN to chesspupil Send a message via Yahoo to chesspupil
Default

Got an error I hope you can help....

Im getting Case without select errors and case without select...
Would these be better off as separate macros as the first one is functional if I delete the items I added in the check box value areas.

I included an updated attachment and you can see the marco below...
Form ending in B has the bad macro, none-B form has only the first macro with not checkbox name changes

And if this works I would like to also have the selection of the PT or MT box cause the selection of a box in 15 or 16 as applicable. If MT is selected the the last box in 15 and if PT is selected then the first box in 16 is selected.

Also, using the machines local date I would like the second block of block 19 and 20 to use the PC's current date.

Sub NameDDOnExit()
Dim oFF As FormFields
Set oFF = ActiveDocument.FormFields
Select Case oFF("Name").Result
Case "USS Florida SSGN-728"
oFF("UIC").Result = "21038"
Case "USS Georgia SSGN-729"
oFF("UIC").Result = "21039"
Case "USS Alaska SSBN-732"
oFF("UIC").Result = "21042"
Case "USS Tennessee SSBN-734"
oFF("UIC").Result = "21044"
Case "USS West Virginia SSBN-736"
oFF("UIC").Result = "21365"
Case "USS Maryland SSBN-738"
oFF("UIC").Result = "21460"
Case "USS Rhode Island SSBN-740"
oFF("UIC").Result = "21682"
Case "USS Wyoming SSBN-742"
oFF("UIC").Result = "21846"
Case "TRF"
oFF("UIC").Result = "44466"
Case "Triper"
oFF("UIC").Result = "00024"
Case "CSS-20"
oFF("UIC").Result = "63976"
Case " "
oFF("UIC").Result = " "
End Select
Case "VT_DIM"
Select Case oFF("VT_DIM").CheckBox.Value
Case "True"
oFF("B11_1").Result = "1C"
Case Else
oFF("B11_1").Result = ""
Case "PT"
Select Case oFF("PT").CheckBox.Value
Case "True"
oFF("B11_2").Result = "4E"
Case Else
oFF("B11_2").Result = ""
Case "MT"
Select Case oFF("MT").CheckBox.Value
Case "True"
oFF("B11_3").Result = "3G"
Case Else
oFF("B11_3").Result = ""
End Select
End Select
End Sub
Attached Files
File Type: doc Misc report rev 5--10 BLANK-B.doc (60.0 KB, 18 views)
File Type: doc Misc report rev 5--10 BLANK.doc (60.0 KB, 14 views)
Reply With Quote
  #8  
Old 05-09-2010, 05:43 AM
gmaxey gmaxey is offline Form Field - Drop down selection causing auto text Windows XP Form Field - Drop down selection causing auto text Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,204
gmaxey has a spectacular aura aboutgmaxey has a spectacular aura aboutgmaxey has a spectacular aura about
Default

You have to be careful when constructing case statements or you will generate errors.

I do this sort of thing for a living now, so I can't continue to build your form for you for free.

Attached is a working document.
Attached Files
File Type: doc Document.doc (76.5 KB, 71 views)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Wrapping on Fixed Lines in a Form field/Table cell okrmjr Word Tables 0 10-30-2009 08:52 AM
Outlook 2007, contacts: drop down in custom field pacecal Outlook 0 06-16-2009 10:43 AM
Form Field - Drop down selection causing auto text Text Form Field formatting problem Toshii Word 1 06-08-2009 07:21 PM
Form Field - Drop down selection causing auto text How can I fill in form I received in email that used underlines instead of text field Gail L. Word 2 05-17-2009 12:38 PM
evaluating a text expression in a form field gwp1 Word 0 10-08-2007 02:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2022 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft