Overview
WinCC 7.x User Archives store process data in ODBC-backed tables that the HMI runtime reads and writes via UA tags, the User Archive Table Control, and the uasql API. When you create a column with the User Archive configuration wizard, the User Archive Field Creation Wizard lets you enter a static Minimum and Maximum value that the runtime enforces when the operator edits the field in the table view. These static bounds are baked into the configuration database at compile time, so they cannot be changed at runtime by the operator.
This article shows how to replace those static bounds with dynamic limits driven by WinCC tags. Three production-ready methods are documented end to end:
- Dynamizing the
LowLimit/HighLimitproperties of a stand-alone I/O field that writes to a User Archive column. - Scripting a pre-write validation routine on the User Archive Table Control's Apply event that compares the operator's value against current tag-driven limit pairs and rejects out-of-range edits.
- Using the User Archive C-API /
uasqlcommands from a global VBScript action to perform server-side validation and write-back.
Prerequisites
| Item | Requirement |
|---|---|
| Engineering system | WinCC 7.4 SP1 / 7.5 / 7.5 SP1 / 7.6, or TIA Portal WinCC Professional V16 or later with the User Archive option installed. |
| Runtime | WinCC Runtime Professional on PC-based panels or WinCC Server (multi-client). Minimum 2 GB free RAM for the UA service. |
| Licensing | WinCC User Archive option (ASIA / Europe license model). 512 archive tags base; expand with archive power-packs in increments of 512. |
| Database back-end | SQLite (default, single-user) or Microsoft SQL Server 2017 / 2019 configured via User Archive Configuration > Database Connection. |
| Required components | VBScript engine, Microsoft JET / ACE OLE DB provider, the file uasql.dll in the WinCC\bin directory. |
| Knowledge prerequisites | Familiarity with WinCC tag configuration, VBScript (HMIRuntime, HMIRuntime.Trace), User Archive wizard, and graphic designer properties dialog. |
Why the Wizard Limits Are Static
The User Archive Field Creation Wizard writes the MinValue and MaxValue columns into the configuration archive (the read-only UA_CONFIG schema). At runtime, the table control consults these values once when constructing the editor cell for the column; they are not re-evaluated on every keystroke. Consequently, even if you change them via the WinCC UserArchiveControl configuration dialog at runtime, open editors already in place will continue to use the original bounds.
To produce bounds that do follow HMI tags, you must move the validation outside of the wizard metadata. The two layers at which this can be done cleanly are:
- The field property layer of a stand-alone I/O field that has been linked to a User Archive tag.
- The script layer invoked by the table control's BeforeWrite / AfterChange / Apply events.
Method 1 — Tag-Dynamized Limits on a Stand-alone I/O Field
This is the simplest and most reliable technique. You keep the User Archive Table Control as a read-only overview, then add an explicit I/O Field for each field the operator must change. The I/O field's LowLimit and HighLimit properties accept direct tag dynamization.
Step 1 — Create the limit tags
Open the Tag Management and add two internal 32-bit float tags:
-
SP_Archive_MinValue(data type:Float, length: 4) -
SP_Archive_MaxValue(data type:Float, length: 4)
Both tags will be writable from the operator screen so the bound can be changed live.
Step 2 — Configure the User Archive tag
In the User Archive editor, define a column Setpoint with:
- Type:
Floating-point number (32-bit IEEE) - Min / Max: set to the broadest engineering range (e.g. -1.0E+30 to 1.0E+30) — the wizard values are placeholders only, the actual enforcement happens in the I/O field.
- Archive:
SP_Setpoint
Step 3 — Drop the I/O field on the screen
- From the Smart Objects palette, place an I/O Field on the process screen.
- In the configuration dialog, set:
-
Tag: select
SP_Setpoint(the archive tag). -
Data format:
999.99(or your engineering format).
-
Tag: select
- Switch to the Properties tab and expand Limits.
Step 4 — Dynamize LowLimit and HighLimit
- Click the small light bulb next to Low limit value > Limit value. Choose Tag and select
SP_Archive_MinValue. - Repeat for High limit value > Limit value and select
SP_Archive_MaxValue. - Activate Apply on input for both.
At runtime, when the operator enters a value outside the current range of those tags, WinCC rejects the input, flashes the field red, and (optionally) triggers a horn or event depending on the messaging configuration. The User Archive itself is never written with an invalid value.
Step 5 — Provide an operator control for the limits
Drop two additional I/O fields, link them to SP_Archive_MinValue and SP_Archive_MaxValue, and (for safety) set their own hard static limits to the broadest engineering range to prevent the operator from typing NaN or absurdly large numbers.
| Object property | Static limit (sanity bound) | Dynamic limit (operational bound) |
|---|---|---|
| Setpoint I/O field — LowLimit | -1.0E+30 | SP_Archive_MinValue |
| Setpoint I/O field — HighLimit | 1.0E+30 | SP_Archive_MaxValue |
| Min I/O field — LowLimit | -1.0E+30 | — (no inner bound) |
| Min I/O field — HighLimit | 1.0E+30 |
SP_Archive_MaxValue (forces Min <= Max) |
| Max I/O field — LowLimit | -1.0E+30 | SP_Archive_MinValue |
| Max I/O field — HighLimit | 1.0E+30 | — |
Method 2 — VBScript Pre-Write Validation on the Table Control
When the operator must edit values directly in the table view (not through stand-alone I/O fields), dynamize the I/O field properties is not possible because the table's edit cell is generated by the control itself. In that case, attach a VBScript action to the table control that runs before the write is committed to the archive.
Step 1 — Expose the table control's events
- Right-click the User Archive Table Control and select Properties > Events.
- Configure the Apply event (or ApplyData on older controls) with the right mouse button > VBS Action.
Step 2 — Write the validation routine
' --- vbs in Apply event of the User Archive Table Control ---
Option Explicit
Dim oUACtl, oReadRow, sFieldName, vNewValue
Dim dMin, dMax, dVal
Set oUACtl = ScreenItems("UACTL_Setpoints")
' Resolve limit tags
dMin = HMIRuntime.Tags("SP_Archive_MinValue").Read
dMax = HMIRuntime.Tags("SP_Archive_MaxValue").Read
' Loop every edited row in the pending buffer
For i = 1 To oUACtl.GetPendingRowCount()
sFieldName = "Setpoint"
vNewValue = oUACtl.GetPendingCellValue(i, sFieldName)
If IsNumeric(vNewValue) Then
dVal = CDbl(vNewValue)
If dVal < dMin Or dVal > dMax Then
HMIRuntime.Trace "UA validation: row " & i & " " & _
sFieldName & "=" & dVal & " outside [" & dMin & "," & dMax & "]" & vbCrLf
oUACtl.RejectPendingRow i, vbTrue ' cancel write of this row
HMIRuntime.Alarm "ArchiveSetpointOutOfRange", _
"Value " & dVal & " rejected. Limits: " & dMin & "..." & dMax
End If
Else
oUACtl.RejectPendingRow i, vbTrue
End If
Next
' Final commit if no rejections
If oUACtl.GetPendingRowCount() > 0 Then
oUACtl.ApplyPending ' WinCC 7.5 SP1 and later
End If
Important behavioral notes:
-
RejectPendingRowrequires WinCC 7.5 SP1 Update 1 or later. On older builds, useoUACtl.CancelPendingto drop the whole edit buffer. -
GetPendingCellValuereturns the value asVariant; always convert withCDblbefore comparison. - The alarm number
ArchiveSetpointOutOfRangemust be defined in WinCC Alarm Logging beforehand.
Method 3 — Direct uasql Validation with Server-side Stored Procedures
For installations running against Microsoft SQL Server, the cleanest enforcement is server-side. Define a CHECK constraint that references a separate configuration table, and update that table from WinCC via uasql.
Step 1 — Define the dynamic limit table
CREATE TABLE dbo.ArchiveLimits (
ArchiveName NVARCHAR(64) NOT NULL PRIMARY KEY,
FieldName NVARCHAR(64) NOT NULL,
MinValue FLOAT NULL,
MaxValue FLOAT NULL
);
Step 2 — Add a CHECK constraint to the data table
ALTER TABLE dbo.UA_Setpoints
ADD CONSTRAINT CK_Setpoint_Range CHECK (
Setpoint >=
ISNULL((SELECT MinValue FROM dbo.ArchiveLimits
WHERE ArchiveName='UA_Setpoints' AND FieldName='Setpoint'), -1E+30)
AND Setpoint <=
ISNULL((SELECT MaxValue FROM dbo.ArchiveLimits
WHERE ArchiveName='UA_Setpoints' AND FieldName='Setpoint'), 1E+30)
);
Step 3 — Update limits from a VBScript action
Dim sCon, sSql, oConn, oCmd
sCon = "Provider=SQLOLEDB;Data Source=WINCC_SRV;Initial Catalog=WinCC;Integrated Security=SSPI;"
sSql = "UPDATE dbo.ArchiveLimits SET MinValue=?, MaxValue=? " & _
"WHERE ArchiveName='UA_Setpoints' AND FieldName='Setpoint';"
Set oConn = CreateObject("ADODB.Connection")
oConn.Open sCon
Set oCmd = CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oConn
oCmd.CommandText = sSql
oCmd.Parameters.Append oCmd.CreateParameter("Min", 5, 1, 8, _
HMIRuntime.Tags("SP_Archive_MinValue").Read)
oCmd.Parameters.Append oCmd.CreateParameter("Max", 5, 1, 8, _
HMIRuntime.Tags("SP_Archive_MaxValue").Read)
oCmd.Execute , , 128 ' 128 = adExecuteNoRecords
oConn.Close
This pattern has the advantage that the constraint is enforced even for direct SQL writes (for example from a script or a third-party SCADA). It also works when the WinCC project is part of a redundant server pair, because the limits are stored in the database rather than in tag memory.
Parameter Mapping Reference
| WinCC object | Property | Dynamization | Effect at runtime |
|---|---|---|---|
| Standard I/O field | Limits > Low limit value > Limit value | Tag, Script, or direct value | Operator input below the dynamic value is rejected, field flashes. |
| Standard I/O field | Limits > High limit value > Limit value | Tag, Script, or direct value | Operator input above the dynamic value is rejected. |
| Standard I/O field | Limits > Apply on input | Boolean (1/0) | If cleared, the limit is checked on commit instead of on each keystroke. |
| Standard I/O field | Limits > Display of limit violation | Boolean | Red background + tooltip when violated. |
| UA Table Control | Events > Apply / ApplyData | VBScript only | Runs before pending rows are written to the archive. |
| UA Table Control | Events > AfterChange (cell) | VBScript only | Per-cell; ideal for inline checkmarks or color highlighting. |
| UA Table Control | Methods > RejectPendingRow | Script only | Drops a single pending row — WinCC 7.5 SP1 Upd1 or later. |
| UA Table Control | Methods > CancelPending | Script only | Drops the entire pending edit buffer. |
| UA Configuration | Field wizard > MinValue / MaxValue | Static only | Baked at compile time; cannot be linked to a tag. |
Verification Procedure
- Compile and download the project to the runtime.
- Open the screen with the I/O field (Method 1) or the table control (Method 2).
- Change
SP_Archive_MinValueto 10 andSP_Archive_MaxValueto 50 via the operator limit fields. - Try entering 5 in the Setpoint I/O field (or table cell). The value must be rejected and the field must show the violation marker.
- Enter 25; the value must be accepted.
- Inspect the User Archive database with the WinCC UserArchive editor or via SQL:
SELECT Setpoint FROM UA_Setpoints;. Confirm that only values inside [10, 50] are present. - Open the WinCC Diagnostics window — Apdiag.exe — and filter on
ua_events. Confirm that no warningUA_RANGE_VIOLATIONis logged.
Troubleshooting Matrix
| Symptom | Likely root cause | Remediation |
|---|---|---|
| Operator can enter any value, no limit applied. | The I/O field's Apply on input flag is cleared. | Properties > Limits > set Apply on input = yes. |
| Limit value flickers between two values. | Tag acquisition cycle too slow compared to operator typing speed. | Reduce the trigger tag's update cycle to 250 ms, or use a Quality Code property reference instead of the value itself. |
| VBScript Apply event does not fire. | Property name in Events is misnamed on the active build (e.g. Apply vs ApplyData). | Check the WinCC Information System for the exact event name on your version. |
RejectPendingRow returns method not supported. |
Build older than WinCC 7.5 SP1 Update 1. | Use CancelPending and inform the operator that the entire buffer was dropped. |
| Tag dynamization shows red exclamation mark in graphics designer. | Connected tag has wrong data type (e.g. INT instead of FLOAT). | Match the data type of SP_Archive_MinValue / SP_Archive_MaxValue to the I/O field's data format. |
| Limit value is overridden by the wizard static value. | You dynamized the I/O field but kept the User Archive wizard value narrower. | Set the wizard Min/Max to the widest engineering range so the I/O field's dynamic limits are the active ones. |
| uasql action fails with provider not found. | 32/64-bit mismatch between WinCC (32-bit) and the OLE DB provider. | Force the 32-bit ACE provider: Provider=Microsoft.ACE.OLEDB.12.0;. |
| Server-side CHECK constraint blocks legitimate writes. | Limits table row missing for the archive / field combination. | Insert a default row in ArchiveLimits with NULL bounds; the ISNULL guard will fall back to ±1E+30. |
Field-Engineering Notes
- The wizard static values still matter when the archive is edited through
WinCC Archive Connectoror a third-party OPC UA client that bypasses the I/O field. Leave the wizard bounds at the broadest engineering range, and apply the operational envelope at the HMI layer. - On redundant WinCC Server pairs, keep the limit tags in internal tag memory and replicate them with Tag Synchronization in the redundancy configurator. Otherwise the standby server will display stale limits after a failover.
- When the operator is allowed to edit limits, log every change to
SP_Archive_LimitLogwith a VBScript action tied to the limit I/O fields. This satisfies FDA 21 CFR Part 11 / EU Annex 11 audit requirements commonly seen in regulated plants. - For multilingual sites, the runtime messages raised by the alarm number
ArchiveSetpointOutOfRangemust exist in every configured language, otherwise the operator sees the WinCC internal English text instead of the translated one. - If the User Archive is configured on a remote SQL Server, the connection string in Method 3 must use Trusted Connection with the WinCC Runtime service account, not the engineer account.
FAQ
Why does the User Archive wizard Min/Max value not update when I change a tag?
The MinValue / MaxValue set in the User Archive Field Creation Wizard is stored in the configuration archive (UA_CONFIG) and is evaluated once when the table control builds its edit cells. Tag dynamization on those entries is not supported. Use Method 1 (I/O field with dynamized LowLimit/HighLimit) or Method 2 (VBScript on Apply) to obtain dynamic behavior.
Can I dynamize the LowLimit / HighLimit of an Edit field that is inside a User Archive Table Control?
No. The cell editor inside the UA Table Control is generated by the control and exposes only the column properties configured in the wizard. To get dynamic limits, replace inline editing with stand-alone I/O fields (Method 1), or attach a VBScript validation to the Apply / ApplyData event (Method 2).
Which WinCC versions support RejectPendingRow?
RejectPendingRow was introduced in WinCC 7.5 SP1 Update 1 and is available in all subsequent 7.5 and 7.6 service packs, as well as WinCC Professional V17 and later in TIA Portal. On older builds use CancelPending to drop the entire pending buffer.
Does the I/O field reject NaN or empty input?
An empty input is rejected only if the I/O field's value tag has the required attribute set. NaN is handled by the runtime: if the data type does not allow NaN (FLOAT), the value is clamped to the configured LowLimit. To prevent NaN explicitly, add an OnChange VBScript that validates IsNumeric before writing back.
How do I make the limit values survive a WinCC redundancy failover?
Mark SP_Archive_MinValue and SP_Archive_MaxValue as part of the redundancy tag set (Tag Synchronization > Synchronized tags) so that the standby server mirrors the values. Alternatively, store the limits in the SQL back-end as shown in Method 3; the database is shared between the redundant servers.