Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2024, 08:59 AM
Angela718 Angela718 is offline Visual Basic Code for a Required Drop Down Menu Form Field Windows 11 Visual Basic Code for a Required Drop Down Menu Form Field Office 2013
Novice
Visual Basic Code for a Required Drop Down Menu Form Field
 
Join Date: May 2024
Posts: 1
Angela718 is on a distinguished road
Default Visual Basic Code for a Required Drop Down Menu Form Field

I have a multiple-page Word form that has many fields, most of which are optional. I have been able to add Visual Basic modules to certain form fields at the beginning of the form to require those fields be completed -- these are fields that contain some type of text or date fields. There are other fields that contain drop down menus, some of which contain 2-3 options, others that contain many more options, but they are all single choice menus. The code I'm using for the text fields does not work with the drop-down fields and I don't know how to write the code to be used with these fields. Can someone provide the code or direct me to a source with this information?
Reply With Quote
  #2  
Old 05-15-2024, 11:43 AM
gmaxey gmaxey is offline Visual Basic Code for a Required Drop Down Menu Form Field Windows 10 Visual Basic Code for a Required Drop Down Menu Form Field Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,602
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

By fields, I will assume you mean formfields. Formfield dropdowns by design can't be empty. They have to contain one of the list items that you define.



E.g., you might define "Choose Letter" as the first entry then A, B, C, D etc.


Sub ValidateFFs()
Dim oFF As FormField
For Each oFF In ActiveDocument.FormFields
Select Case oFF.Name
Case "Dropdown1"
If oFF.Result = "Choose Letter" Then
oFF.Range.Select
MsgBox "This field must have a valid selection"
Exit For
End If
Case "Text1"
'Your code for validating the Text1 field.

End Select
Next oFF
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Code for a Required Drop Down Menu Form Field Code line for adding Building Blocks to a macro in Visual Basic proking Word VBA 9 01-07-2020 10:05 AM
Activate (show) a Drop-down form field when another drop-down form field is selected from Jentis Word VBA 1 04-19-2018 09:42 PM
Word Form/ActiveX drop down menu/value in a different field AMackenzieFFCU Word VBA 1 01-14-2013 07:48 AM
Visual Basic Code for a Required Drop Down Menu Form Field Visual basic code for Word 2003 template KateAus Word VBA 4 09-09-2012 08:40 PM
Visual Basic Code for a Required Drop Down Menu Form Field How to I make text Bold in a User Form -Visual Basic gurp99 Word VBA 11 03-12-2012 04:05 PM

Other Forums: Access Forums

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


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