I am trying to clear a field if the user selects NO for a prompt. everything works but the field does not clear. Please review my code below and tell me if it something obvious i am missing.
Function CheckValidations
' ============================================================================
'
' Checks validations on form
' This was moved from QuerySave prior to deployment due to bugs in "Request for Information"
' (which needs to checkvalidations)
'
' ============================================================================
On Error Goto ErrHandle
'
Dim intNeedToCheck As Integer
Dim aryStrErrors() As String
Dim strError As String
Dim strFieldGoto As String
Dim intErrorCount As Integer
Dim IntAnswer As Variant
'
intErrorCount = -1 'This counts the number of errors on the form. If -1, then no errors found
'As in this form as well as the client master, this type of error checking shold be taken out.
'PWC prefers that the error be reported as soon as it occurs rather than showing all at once
'
' Header validations
'
If gDoc.getItemValue( "client")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select or create client information.|
End If
'
If gDoc.getItemvalue( "clientCode")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter a client code.|
If strFieldGoto = "" Then
strFieldGoto = "ClientCode"
End If
End If
'
%REM
If Len(gDoc.ClientCode(0))<>6 Or Instr(1, gDoc.ClientCode(0), " ")<>0 Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Client code must be six non-blank characters.|
If strFieldGoto = "" Then
strFieldGoto = "ClientCode"
End If
End If
'
If Not(gDoc.ClientProjectCodeEdit(0) Like "????-??") Or Instr(1, gDoc.ClientProjectCodeEdit(0), " ")<>0 Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Client project code must be formatted as xxxxxx-xxxx-xx.|
If strFieldGoto = "" Then
strFieldGoto = "ClientProjectCodeEdit"
End If
End If
%END REM
'
If gDoc.getItemValue( "Office")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select an office.|
If strFieldGoto = "" Then
strFieldGoto = "office"
End If
End If
'
If gDoc.getItemValue( "Industry")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select an industry.|
If strFieldGoto = "" Then
strFieldGoto = "industry"
End If
End If
'
If gDoc.getItemvalue( "sector")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter a sector.|
If strFieldGoto = "" Then
strFieldGoto = "sector"
End If
End If
'
If gDoc.getItemValue( "partners")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select the engagement partner(s).|
End If
'
If gDoc.getItemValue( "partnersPhone")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)="Please enter the engagement partner phone number(s)."
If strFieldGoto = "" Then
strFieldGoto = "partnersPhone"
End If
End If
'
If gDoc.getItemvalue( "Managers")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select the engagement manager(s) .|
End If
'
If gDoc.getItemValue( "managersPhone")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)="Please enter the engagement manager phone number(s)."
If strFieldGoto = "" Then
strFieldGoto = "managersPhone"
End If
End If
'
If gDoc.getItemValue( "concurringPartners")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select the concurring partner(s).|
End If
'
If gDoc.getItemValue( "CCPartnersPhone")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)="Please enter the concurring partner phone number(s)."
If strFieldGoto = "" Then
strFieldGoto = "CCPartnersPhone"
End If
End If
'
If gDoc.getItemvalue( "projectPartner")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select a project partner.|
End If
'
If gDoc.getItemValue( "projectPartnerPhone")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)="Please enter the project partner phone number."
If strFieldGoto = "" Then
strFieldGoto = "projectPartnerPhone"
End If
End If
'
If gDoc.getItemvalue( "projectManager")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select a project manager.|
End If
'
If gDoc.getItemValue( "projectManagerPhone")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)="Please enter the project manager phone number."
If strFieldGoto = "" Then
strFieldGoto = "projectManagerPhone"
End If
End If
'
If gDoc.getItemValue( "frisk")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select if the company is considered high risk.|
If strFieldGoto = "" Then
strFieldGoto = "frisk"
End If
End If
'
If gDoc.getItemValue( "companyYearEnd")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter a company year end date.|
If strFieldGoto = "" Then
strFieldGoto = "companyYearEnd"
End If
End If
'
If gDoc.getItemValue( "ClientType")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Is this client subject to PwC's Continous Review requirements set forth in SEC 1100.213?.|
If strFieldGoto = "" Then
strFieldGoto = "ClientType"
End If
End If
' Questions 1-5 validations
'
intNeedToCheck = True 'Say we have to check questions 1 thru 5
If gDoc.hasItem( "noNeedToCheck") Then 'This comes from th request POE Information on the form
intNeedToCheck = False
End If
'
If intNeedToCheck = True Then 'Only if we need to check questions 1 thru 5
If gDoc.getItemValue( "documentType")(0)="" Then '1st Important Question
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please select a document type.|
If strFieldGoto = "" Then
strFieldGoto = "documentType"
End If
End If
'
If gDoc.getItemvalue( "documentType")(0)="OTHER" Then
If gDoc.getItemValue( "documentTypeOth")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please provide a description for the 'Other' document type.|
If strFieldGoto = "" Then
strFieldGoto = "documentTypeOth"
End If
End If
End If
'
If gDoc.getItemvalue( "consultationsNational")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter any consultation with the national office.|
If strFieldGoto = "" Then
strFieldGoto = "consultationsNational"
End If
End If
'
If gDoc.getItemvalue( "consultationsNational")(0)="Yes" And Trim$(gDoc.getItemvalue( "consultationsNationalTopic")(0))="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please describe the nature of the consulation with the national office.|
If strFieldGoto = "" Then
strFieldGoto = "consultationsNationalTopic"
End If
End If
'
If gDoc.SECAvailableEstCal(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter a date when this Document Review Request will be available for SEC review.|
If strFieldGoto = "" Then
strFieldGoto = "SECAvailableEstCal"
End If
End If
'
If gDoc.SECCommentEstCal(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter a date when SEC comments are requested.|
If strFieldGoto = "" Then
strFieldGoto = "SECCommentEstCal"
End If
End If
'
If gDoc.getItemValue( "estFilingDateCal")(0)="" Then
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Please enter an estimated filing date.|
If strFieldGoto = "" Then
strFieldGoto = "estFilingDateCal"
End If
End If
'
End If
'jw start 07/04added code below to validate date fields - Estimate filing date cannot be in the past
Dim dateTime As New NotesDateTime( "" )
dateTime.LSLocalTime = Now
If gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableEstCal")(0) Or _
gDoc.getitemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECAvailableActCal")(0) Or _
gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECCommentEstCal")(0) Or _
gDoc.getItemValue("estFilingDateCal")(0) < gDoc.getItemValue("SECCommentActCal")(0) And _
gDoc.GetItemValue("estFilingDateCal")(0) < ("dateTime.LSLocalTime") Then
'If Messagebox("Is this a post filing review?", MB_YESNO + MB_ICONQUESTION, "Post Filing Review") = IDNO Then
IntAnswer= Messagebox("Is this a post filing review?", MB_YESNO + MB_ICONQUESTION, "Post Filing Review")
If IntAnswer = IDNO Then
'Msgbox ("Estimate Filing Date cannot be in the past")
intErrorCount=intErrorCount+1
Redim Preserve aryStrErrors(intErrorCount)
aryStrErrors(intErrorCount)=|Estimate Filing Date cannot be in the past.|
If gDoc.getItemValue( "estFilingDateCal")(0)="" Then
' If strFieldGoto <> "" Then
' strFieldGoto = "estFilingDateCal"
' gdoc.estFilingDateCal = ""
Call gDoc.FieldClear( "estFilingDateCal")
' Call gDoc.FieldSetText(strFieldGoTo, "") ' cannot clear date/time field estFilingDateCal
End If
End If
End If
'jw end 07/04added code below to validate date fields - Estimate filing date cannot be in the past
' In here i got very confused. the specifications never said on how the delete a poe should really work
' it used to be that i wanted the poe to be valid before i would allow them to save the document.
' however now i was told to just mark it and move on. the problem that can happen somewhere down the
' line is that the user went in here and filled in certain questions - they never did the save
' of the document - no emails go out - because maybe it was in completed status - maybe awaiting
' stauts nad they filled in questions 1- 5. it was a bad way to go - because you will never be sure
' of the document being in the proper way the user had it
If intErrorCount <> -1 Then
' If users ever ask to see all error messages at once, the following commented code will do it
’ gDoc.test=aryStrErrors
’ Dim vtest As Variant
’ vTest=Evaluate(“@Implode(test;@NewLine)”, gDoc)
’ Msgbox vtest(0), MB_OK + MB_ICONSTOP, “Missing Document Review Request Information”
Msgbox aryStrErrors(0), MB_OK + MB_ICONSTOP, "Missing Document Review Request Information"
If strFieldGoto <> "" Then
Call gUiDoc.gotoField( strFieldGoto)
End If
CheckValidations=False
Exit Function
End If
'
CheckValidations=True
Exit Function
'
ErrHandle:
Call ErrorRoutine("CheckValidations")
CheckValidations=False
Exit Function
End Function