Question: I want to have my own validation flow, with custom layout and message.
By default, the validation from the form builder put all the error message beside the input field. And it will validate all fields at once after submit.

I want to validate field by field after submitting, and error message is displayed in the same place for all the input fields (beside the submit button/on top of the form).

Currently I'm trying custom form layout with "ASCX" type. Is it possible to do all the validation in the back-end code ".cs"?

Or I must inject java script at the custom form layout design in source mode?

Or there is any better way to do it?

Answer: 
In case you have only these 2 `PivotTable` in "DD" worksheet, and you want to update these 2 based on the same `PivotCache`, then replace the following `For` loop :

```
With PvtTbl
    .ChangePivotCache PvtCache
    .RefreshTable
End With

```

With the following `For` loop:

```
' refresh all Pivot Tables in "DD" worksheet
For Each PvtTbl In Worksheets("DD").PivotTables
    With PvtTbl
        .ChangePivotCache PvtCache
        .RefreshTable
    End With
Next PvtTbl

```

---

**Edit 1**: `Set` the `PivotCache` inside the `For` loop, and clear it at the end. use the loop below, and remove the `Set PvtCache` line from it's previous place.

```
' refresh all Pivot Tables in "DD" worksheet
For Each PvtTbl In Worksheets("DD").PivotTables
    ' Create/Update Pivot Cache
    Set PvtCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, PvtDataRng)

    With PvtTbl
        .ChangePivotCache PvtCache
        .RefreshTable
    End With

    Set PvtCache = Nothing ' <-- clear the Pivot Cache
Next PvtTbl

```
I haven't tested this myself but you could try and tell me if it works. It seems like it may work for you

```
Function refreshPTcontent()

Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem

On Error Resume Next
    For Each ws In ActiveWorkbook.Worksheets
       For Each pt In ws.PivotTables
         pt.RefreshTable
       Next pt
    Next ws

End Function

```