When working with multi-record blocks in Oracle Forms, users often find it difficult to know which record they are currently editing or navigating. By default, Oracle Forms does not provide a strong visual indicator of the current row. To improve user experience, developers can implement highlighting for the current record. This article explains how to Highlight the Current Record in a Multi-Record Block in Oracle Forms using practical techniques, triggers, and properties.
Why Highlighting the Current Record is Important
In multi-record blocks, several rows are displayed on the screen simultaneously. Without a clear indication of the active row, users may:
- Enter data in the wrong record.
- Lose track of navigation while scrolling.
- Accidentally overwrite existing information.
- Make errors in validation or updating records.
By highlighting the current record, you make your forms more user-friendly and minimize the chances of errors.
Built-in Options for Record Highlighting
Oracle Forms provides some features that can be used to highlight the current record:
- Visual Attributes – Custom styles like background color, foreground color, or font changes.
- Current Record Visual Attribute (CRVA) – A block-level property that defines how the current record should appear.
- Triggers – Especially
WHEN-NEW-RECORD-INSTANCEandWHEN-VALIDATE-RECORD, which can be used to change visual attributes dynamically.
Using Current Record Visual Attribute (CRVA)
The simplest way to highlight the current record is by setting a Current Record Visual Attribute at the block level.
Steps:
- Create a visual attribute in the Object Navigator (for example,
VA_HIGHLIGHT) with a distinctive background color and font style. - Select the multi-record block.
- In the Property Palette, locate Current Record Visual Attribute Group.
- Assign the created visual attribute (
VA_HIGHLIGHT) to it.
With this setup, the current record will automatically be highlighted whenever the user navigates through the block.
Using WHEN-NEW-RECORD-INSTANCE Trigger
If you need more control over record highlighting, you can use the WHEN-NEW-RECORD-INSTANCE trigger. This allows dynamic styling of the active row.
Example:
BEGIN
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.ENAME', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_HIGHLIGHT');
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.SALARY', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_HIGHLIGHT');
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.JOB', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_HIGHLIGHT');
END;
Here:
- Each item in the block (ENAME, SALARY, JOB) is styled with the
VA_HIGHLIGHTvisual attribute. - Only the active record is highlighted.
Restoring Previous Records’ Visual Attributes
One challenge with using triggers is that the previous record may remain highlighted. To avoid this, reset the visual attributes in the WHEN-VALIDATE-RECORD or WHEN-NEW-RECORD-INSTANCE trigger.
Example Reset Code:
BEGIN
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.ENAME', PREVIOUS_RECORD, VISUAL_ATTRIBUTE, 'VA_DEFAULT');
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.SALARY', PREVIOUS_RECORD, VISUAL_ATTRIBUTE, 'VA_DEFAULT');
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.JOB', PREVIOUS_RECORD, VISUAL_ATTRIBUTE, 'VA_DEFAULT');
END;
This ensures that only the current record remains highlighted while others retain the default attribute.
Combining CRVA with Dynamic Control
A best practice is to use CRVA for general highlighting and extend it with triggers for specific conditions. For example, you may want to highlight the current record in blue, but also highlight invalid records in red.
Example with Conditional Highlighting:
BEGIN
IF :EMP_BLOCK.SALARY < 1000 THEN
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.SALARY', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_ERROR');
ELSE
SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.SALARY', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_HIGHLIGHT');
END IF;
END;
Best Practices for Record Highlighting
- Define visual attributes carefully: Use colors that are easy to distinguish but not distracting.
- Keep consistency: Apply the same highlighting logic across all blocks for uniformity.
- Avoid performance overhead: Limit trigger code to essential properties to keep navigation smooth.
- Use contrast wisely: Make sure text is always readable against the background color.
- Test with end users: Ensure that the chosen highlight style works well in real scenarios.
Common Mistakes to Avoid
- Over-highlighting: Using too many colors can confuse users. Stick to one or two highlight attributes.
- Forgetting to reset attributes: If you don’t reset, multiple rows may stay highlighted at once.
- Using restricted triggers: Avoid placing navigation or attribute-changing logic in triggers where it’s not allowed (e.g.,
WHEN-VALIDATE-ITEM). - Hardcoding visual attributes: Always define them in Object Navigator for easier maintenance.
Conclusion
Highlighting the current record in a multi-record block is a simple but highly effective enhancement in Oracle Forms. The easiest method is to use the Current Record Visual Attribute (CRVA) property at the block level. For more advanced control, developers can use triggers like WHEN-NEW-RECORD-INSTANCE along with SET_ITEM_INSTANCE_PROPERTY to apply conditional styling.
By implementing these techniques, you can greatly improve the usability of your forms and reduce user errors. Always aim for a clean, consistent, and user-friendly highlighting approach.

