Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 07-26-2022, 12:30 PM
CellCharger CellCharger is offline Make a field required Windows 10 Make a field required Office 2019
Novice
Make a field required
 
Join Date: Oct 2021
Location: NJ, USA
Posts: 24
CellCharger is on a distinguished road
Default

Thank you Andrew,

Please excuse my lack of knowledge.

I fixed the field tags but when I pasted the code below the existing code, I get the error message (see the attachment).

And just for the record, the the first code was from another post that I created.



this is the code

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim Dt As Date, StrDt As String
With CCtrl
  If .Title <> "Date of Initiation" Then Exit Sub
  If .ShowingPlaceholderText = True Then
    ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = ""
  Else
    StrDt = .Range.Text
    If IsDate(StrDt) Then
      Dt = CDate(StrDt)
    Else
      Dt = CDate(Split(StrDt, (Split(StrDt, " ")(0)))(1))
    End If
    ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = Format(Dt + 30, .DateDisplayFormat)
  End If
End With
Application.ScreenUpdating = True
End Sub
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Tag
    Case "Rev. #"
      If ContentControl.ShowingPlaceholderText Then
        MsgBox "Rev. # requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
    Case "PDR #"
      If ContentControl.ShowingPlaceholderText Then
        MsgBox "PDR # requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
    Case "Date of Discovery"
      If ContentControl.ShowingPlaceholderText Then
        MsgBox "Date of Discovery requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
    Case "Type"
      If ContentControl.ShowingPlaceholderText Then
        MsgBox "Type requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
    Case "ManNum"
      If Not IsNumeric(ContentControl.Range.Text) Then
        MsgBox "This field requires a numeric response.", vbInformation + vbOKOnly, "INPUT REQUIRED"
        Cancel = True
      End If
  End Select
lbl_Exit:
  Exit Sub
End Sub
I attached the form just in case.
Attached Images
File Type: jpg Error.jpg (28.5 KB, 29 views)
Attached Files
File Type: docm Report Due Date (1) fixed.docm (56.5 KB, 10 views)

Last edited by CellCharger; 07-27-2022 at 05:49 AM.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make a field required how to make a template with field and mailmerge to work together in protected mode pjkon Mail Merge 1 06-10-2019 04:35 PM
How To Make 2013 Populate To Field abraxis Outlook 2 08-10-2018 06:41 AM
Make a field required How to make a Check Box Form Field red if not checked? CarlCR Word Tables 3 07-12-2016 08:35 PM
Make a field required How to make a SEQ field show up in cross references? Roscoe Word 5 06-01-2016 01:39 PM
make text form field active dependent on dropdown Glenn0004 Word VBA 1 06-23-2015 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:58 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