Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-01-2016, 03:42 AM
samrosen samrosen is offline Mac OS X Office 2016
Novice
 
Join Date: Aug 2016
Posts: 3
samrosen is on a distinguished road
Default Combo Box and AutoFill

Hey!

I having been reading this and can't find a conclusive answer.

I want to create a form that contains a combo box. When Q1 is selected I want it to auto fill January, February, March.



I'd love it to do the same thing for Q2/Q3/Q4.

Is this possible?

Thanks,

Sam
Attached Images
File Type: png Screen Shot 2016-08-01 at 11.39.40.png (16.4 KB, 21 views)
File Type: png Screen Shot 2016-08-01 at 11.39.44.png (12.1 KB, 21 views)
Reply With Quote
  #2  
Old 08-01-2016, 03:10 PM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 795
gmaxey will become famous soon enough
Default

What kind of fields? Your graphic looks like formfields, but there is no combo box in the formfield collection.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 08-02-2016, 12:55 AM
samrosen samrosen is offline Mac OS X Office 2016
Novice
 
Join Date: Aug 2016
Posts: 3
samrosen is on a distinguished road
Default

Hi!

I created these as Combo Boxes. I've uploaded an example of what I am looking to do as an attachment also if that helps.

Thanks,

Sam
Attached Images
File Type: png Screen Shot 2016-08-02 at 08.54.26.png (89.1 KB, 15 views)
Attached Files
File Type: docx Quarter Test.docx (24.5 KB, 3 views)
Reply With Quote
  #4  
Old 08-02-2016, 07:55 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 795
gmaxey will become famous soon enough
Default

Sam,

I don't know where that user interface came from but that is not a combobox it is a dropdown formfields. Comboboxes let you type in alternate text not part of the list.

You will need to set a macro to run on exit from the dropdown:

Code:
Sub ConvertQtrToMonths()
  With ActiveDocument
    .FormFields("Text1").Enabled = True
    .FormFields("Text1").Enabled = True
    .FormFields("Text1").Enabled = True
    Select Case .FormFields("Dropdown1").Result
      Case "Q1"
        .FormFields("Text1").Result = "January"
        .FormFields("Text2").Result = "February"
        .FormFields("Text3").Result = "March"
      Case "Q2"
        .FormFields("Text1").Result = "April"
        .FormFields("Text2").Result = "May"
        .FormFields("Text3").Result = "June"
      Case "Q3"
      
      Case "Q4"
      
    End Select
'    .FormFields("Text1").Enabled = False
'    .FormFields("Text1").Enabled = False
'    .FormFields("Text1").Enabled = False
  End With
lbl_Exit:
  Exit Sub
End Sub
If there is another field in your form then you can disable the three month text boxes. Otherwise you have to leave at least one enable so you will have somewhere to exit to.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 08-03-2016, 04:01 AM
samrosen samrosen is offline Mac OS X Office 2016
Novice
 
Join Date: Aug 2016
Posts: 3
samrosen is on a distinguished road
Default

Hi Gmaxey! This is amazing, thank you so much.

Out of interest, I have to click on the text boxes in order to get it to work (see attached Video). Is there a way around this, or is it the behaviour of word?
Attached Files
File Type: zip Macro v2.mp4.zip (343.1 KB, 5 views)
Reply With Quote
  #6  
Old 08-03-2016, 05:12 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 795
gmaxey will become famous soon enough
Default

It isn't that you have to click on one of the text boxes, but you have to exit the dropdown field. If those three text boxes are the only other formfields in the document then clicking one of them is the only exit point available.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autocomplete With Combo Box JPMontoya Word 1 12-08-2015 01:41 PM
Creating AutoFill form - AutoFill information depending on a selection. RyanHarper Word 3 06-15-2015 01:01 PM
Combo Box Items BoringDavid Word VBA 12 12-12-2013 05:14 AM
Combo Box Hinchy Word 4 09-04-2012 05:31 AM
Hide a combo box DrewB Word 3 06-08-2009 11:29 PM


All times are GMT -7. The time now is 06:53 PM.


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