Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-11-2023, 07:58 PM
Guessed's Avatar
Guessed Guessed is offline Verify date based on dropdown selection Windows 10 Verify date based on dropdown selection Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Set the title in the date CC to 'Effective Date' and then add this code to the ThisDocument module


Code:
Private Sub Document_ContentControlOnExit(ByVal oCC As ContentControl, Cancel As Boolean)
  Dim ccDate As ContentControl, dteEffectiveDate As Date
  If oCC.Title = "Type of Transaction" Then
    Select Case oCC.Range.Text
      Case "Reclassification", "Transfer", "Change of Pay Rate"
        Set ccDate = ActiveDocument.SelectContentControlsByTitle("Effective Date")(1)
        If Not ccDate.ShowingPlaceholderText Then
          dteEffectiveDate = CDate(ccDate.Range.Text)
          If Format(dteEffectiveDate, "ddd") <> "Mon" Then
            ccDate.Range.Select
            MsgBox "You silly billy, the effective date has to be a Monday now you've chosen that!", vbOKOnly + vbCritical, "WTF"
          End If
        End If
    End Select
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 12-27-2023, 11:57 AM
kkline116 kkline116 is offline Verify date based on dropdown selection Windows 10 Verify date based on dropdown selection Office 2016
Novice
Verify date based on dropdown selection
 
Join Date: Jul 2020
Posts: 5
kkline116 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Set the title in the date CC to 'Effective Date'
First, my apologies for the late response, it's been a hectic couple of weeks...

2nd, THANK YOU for your help with this...

The Code looks great... but maybe I don't know how to set the title? I went to the Effective Date CC, right clicked and went to Table Properties, then went to "Alt Text" and put in Effective Date in the "Title" field:

I get an error that says, "Run-time error '5941': The requested member of the collection does not exist." When I hit Debug, it highlights the line:

Code:
Set ccDate = ActiveDocument.SelectContentControlsByTitle("Effective Date")(1)
Thanks in advance for any help!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Text based on selection of dropdown list cloud67 Word VBA 2 08-09-2019 06:46 AM
Reveal portion of document based on dropdown selection chappeja Word VBA 1 03-27-2019 08:36 PM
Selection of a dropdown creates another dropdown wih the list krishnamurthy.ka2810 Word VBA 1 04-26-2018 11:44 PM
Verify date based on dropdown selection Dropdown selection value coconutt Word VBA 5 09-13-2012 05:23 PM
Macro to populate a text form field based on dropdown selection koloa Word 0 10-20-2011 11:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:53 AM.


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