The 3D Text Wizard was first introduced in a series of articles published in September 2006. I originally created this website to share practical tips and techniques, many of which I had applied in real-world projects while working for an automotive company in the Sultanate of Oman. At that time, the wizard demonstrated the QBColor version, providing a simple way to explore color effects.
The updated 3D Text Wizard now supports the full RGB color spectrum, making color selection significantly more flexible. To further enhance customization, a dedicated ColorList table has been added, allowing users to extend the available palette with their own preferred colors.
This feature is particularly useful for creating three-dimensional text effects for form headings or for displaying field values, such as employee names or product names. These enhancements make the displayed text more visually appealing and easier to distinguish, especially when viewed from a distance.
Example-1: Employee Name.
Example-2:Order Details Form View-2
The 3D Text Wizard Image is given below:
The event procedures and functions in the 3D Text Wizard have been streamlined in line with the new Event Procedure Coding Rules implemented in the standalone class module. This structured approach improves code organization and readability while making maintenance and future development more efficient.
3D Text Creation Technique.
The 3D text effect is created by layering multiple Label controls or Text Boxes, each displaying the same text. Alternatively, the effect can be produced manually by placing a label or text box with an attractive foreground color on top and positioning additional layers with a darker foreground color behind it, slightly offset toward one of the four corners—top-left, top-right, bottom-left, or bottom-right. This technique creates a shadow effect that enhances the visual appearance of the text.
Manually creating this effect each time can be both tedious and inefficient. As demonstrated in earlier articles, I created form headings using only two labels to achieve a simple yet effective 3D appearance.
On the left side of the Text Wizard interface is a ListBox that displays a collection of colors. This ListBox is bound to a table named Colors, allowing you to add additional color codes whenever required.
To the right of the Colors List are two Option Group controls. The upper Option Group contains two choices. When the first option button is selected, the color chosen from the ListBox is displayed in the upper rectangle control and is applied to the caption of the topmost Label or to the font color of the Text Box used to create the 3D text.
When the second option button is selected, the color chosen from the ListBox is applied as the border color in the first two Text Wizards—Border 2D and Border 3D. All other Text Style Wizard options use only the ForeColor property.
The 3D Text Shadow Positions.
At the top right, there is a ComboBox with four options (0-3) to specify the light and shadow positions for the 3D Text.
Shadow Positions:
0 - Left Top Corner.
1 - Left Bottom Corner.
2 - Right Top Corner
3 - Right Bottom Corner
The first text style, 2D, creates a white border around the text and requires no additional configuration. For both the 2D and 3D text styles, the wizard generates the effect by creating five or seven labels with the same text but with different ForeColor values. These labels are positioned beneath the top label and slightly offset to produce the desired visual effect.
For the 2D border style, the underlying labels are positioned toward the four corners of the top label, creating the appearance of a border surrounding the text.
3D Text Control Types.
The ComboBox positioned below the Shadow Style ComboBox offers two options and utilizes two types of controls to generate the 3D Text.
1 - Label
2 - TextBox
The first option is good for creating Static Headings on Forms or Reports.
The second option creates 3D text using Text Box controls. This style is particularly useful for displaying data from form or report fields by using expressions, as illustrated in the examples shown at the top of this page.
After selecting the desired options, click the Create 3D Text command button to generate the 3D text. The generated text is displayed in the Detail section of a new form. Beneath it, an instructional label provides guidance on modifying the text, font, font size, and font styles, such as Bold, Italic, and Underline, if required. To edit the generated text, carefully select the top Label or Text Box without changing its position, and then modify the label caption or the Text Box contents as needed.
After completing the modifications, select all the Label or Text Box controls by dragging a selection rectangle around them. Then copy and paste the entire group to the desired location.
To display data from form fields in the Text Box controls, assign an expression—such as `=[First Name] & " " & [Last Name]`—to the Control Source property after selecting all the Text Box controls that make up the 3D text.
After generating a text style, you can save it within the 3D Text Wizard for future use. It can then be imported into other projects and modified as required.
With the event procedures consolidated in a standalone intermediary class module, only a single wrapper class is required to handle all the Command Button controls on the form.
The form contains only one ListBox control, and its Click event is handled by a procedure in the intermediary class module.
Similarly, the form contains two Option Group controls. One is used to select the 3D text style, while the other manages the ForeColor and BackColor parameter selection. The BackColor option applies only to the first two text styles—2D and 3D Border. When either of these styles is selected, the BackColor option is enabled; otherwise, it remains disabled.
Because these actions are controlled through the Text Style Option Group, a separate wrapper class for the Option Group controls is unnecessary. The ListBox and Option Group controls are declared as object instances in the intermediary class module using the WithEvents keyword, allowing their events to be handled directly within that class.
The form also contains two ComboBox controls. One is used to select the required 3D text shadow option, while the other is used to choose whether the output should be created as a Label or a Text Box. These ComboBox controls do not require any event procedures.
The Form Module VBA Code.
Both the ListBox and the Option Group Control's Click Events are enabled in the Class_Init() subroutine, and corresponding subroutines are written in this module. First, the Form Module Code is listed below:
Option Compare Database Option Explicit Private W As TWiz_Obj_Init Private Sub Form_Load() Set W = New TWiz_Obj_Init Set W.w_frm = Me End Sub Private Sub Form_Unload(Cancel As Integer) Set W = Nothing End Sub
The TWiz_Obj_Init class is declared in the Module's global area with the object name 'W.' In the Form_Load() event procedure, the object is instantiated, and the current form object (Me) is passed to the W.w_frm() Property Procedure. When the form is closed, the class object 'W' is released from memory.
The TWiz_Obj_Init Class Module Code is Listed Below.
Option Compare Database
Option Explicit
Private wcmd As TWiz_CmdButton
Private WithEvents lst As Access.ListBox
Private WithEvents opt As Access.OptionGroup
Private wfrm As Access.Form
Private Coll As New Collection
Public Property Get w_frm() As Form
Set w_frm = wfrm
End Property
Public Property Set w_frm(ByRef vfrm As Form)
Set wfrm = vfrm
DoCmd.Restore
Call Class_Init
End Property
Private Sub Class_Init()
Dim ctl As Control
Const EP = "[Event Procedure]"
Set opt = wfrm.TxtStyle '3D Text Styles
opt.OnClick = EP
Set lst = wfrm.ColorList 'List of Colors
lst.OnClick = EP
For Each ctl In wfrm.Controls
Select Case TypeName(ctl)
Case "CommandButton"
Select Case ctl.Name
Case "cmd3D", "cmdClose"
Set wcmd = New TWiz_CmdButton
Set wcmd.c_Frm = wfrm
Set wcmd.c_cmd = ctl
wcmd.c_cmd.OnClick = EP
Coll.Add wcmd
Set wcmd = Nothing
End Select
End Select
Next
End Sub
Private Sub lst_Click()
Dim cl As Long
cl = lst.Value
Select Case lst.Name
Case "ColorList"
If wfrm.FBack = 1 Then
wfrm.Fore.BackColor = cl
wfrm.CFore = cl
Else
wfrm.Back.BackColor = cl
wfrm.CBack = cl
End If
End Select
End Sub
Private Sub opt_Click()
Dim opval As Integer
Select Case opt.Name
Case "TxtStyle"
opval = opt.Value
With wfrm.cboStyle
If opval > 1 Then
.Enabled = True
Else
.Enabled = False
End If
End With
With wfrm.Opt2
Select Case opval
Case 1, 2
.Enabled = True
Case Else
.Enabled = False
End Select
End With
End Select
End Sub
Private Sub Class_Terminate()
Do While Coll.Count > 0
Coll.Remove 1
Loop
End Sub
The following ListBox and OptionGroup Control declarations are placed in the Global area of the Class Module.
Private WithEvents lst As Access.ListBox Private WithEvents opt As Access.OptionGroup
The following statements in the Class_Init() Subroutine assign the References from these Objects in the Form and enable their Click Events by assigning the "[Event Procedure]" text in their Event Properties:
Set opt = wfrm.TxtStyle '3D Text Styles
opt.OnClick = EP
Set lst = wfrm.ColorList 'List of Colors
lst.OnClick = EP
Both these objects, Sub lst_Click() and Sub opt_Click() Event Subroutines, are written below the Sub Class_Int() Procedure.
The Command Button Wrapper Class Module.
There is only one Wrapper Class for both the CommandButtons on the Form. All the Wizard Functions are called from the Command Button with the Caption Create 3D Text Click Event Procedure, depending on the 3D Text Style Option selected.
The CommandButton Wrapper Class Subroutine that calls the Wizard Functions is listed below for reference.
Option Compare Database
Option Explicit
Private WithEvents cmd As Access.CommandButton
Private cfrm As Access.Form
Public Property Get c_Frm() As Form
Set c_Frm = cfrm
End Property
Public Property Set c_Frm(ByRef vfrm As Form)
Set cfrm = vfrm
End Property
Public Property Get c_cmd() As CommandButton
Set c_cmd = cmd
End Property
Public Property Set c_cmd(ByRef vcmd As CommandButton)
Set cmd = vcmd
End Property
Private Sub cmd_Click()
Select Case cmd.Name
Case "cmd3D"
Call Create3D(cfrm) 'Call the 3D Text Wizard
Case "cmdClose"
If MsgBox("Close the 3DTextWizard? ", vbYesNo + vbQuestion, "cmdClose_Click()") = vbYes Then
DoCmd.Close acForm, cfrm.Name
End If
End Select
End Sub
The Cmd3D Click Event Subroutine invokes the Create3D(cfrm) Subroutine and passes the Form Object as a Parameter. This Subroutine in the Standard Module gathers the 3D Text Wizard option settings from the Form into related variables and then calls the wizard function based on the selected text style. Each Wizard function, such as Border2D(), calls three different programs to create the 3D Text.
For example, the Border2D Wizard calls the following three Functions to complete the full task of creating the 3D Text:
- FormTxtLabels() ' Creates a Form and the Label or Text Controls
Validate_Dup() ' Performs a Validation check.
MsgLabel() 'Creates a Label control with instructions to use the 3D Text.
Listing all the Wizard VBA codes here is not feasible due to their large volume. However, the 3DTextWizard Demo Database is attached with all the code. You can download it from the link provided at the end of this Page. All the Wizard VBA codes are available in the TxtWizard Standard Module.
Visit the following Links to Articles published earlier for more details on the Wizard Functions:
Demo Database Download Link.
Streamlining Form Module Code in Standalone Class Module.
- Re-using Form Module VBA Coding for New Projects.
- Defining Custom Events in Microsoft Access Part Two
- Objects and Their Built-in Events Part 3.
- Standalone Class Module and Events - Part Four
- Several TextBoxes and Event Capturing Part Five
- Class Objects and Wrapper Classes - Part Six
- Form Module vs. Reusable Class Module Coding Demo - Part Seven
- Collection Object replaces Class Object Array - Part Eight
- Reusability of Streamlined VBA Code - Part Nine
- Organizing Wrapper Classes for Different Forms - Part Ten
- ComboBox and Option-Group Wrapper Classes - Part Eleven
- Report Module Code in Class Module - Part Twelve
- Hiding Report Lines Conditionally - Part 13.
- Form Report Detail Sections Event Handling - Part 14.
- New Custom-Made Form Wizard VBA - Part 15.
- New Custom-Made Report Wizard - Part 16.
- Streamlining VBA External Files List in Hyperlinks-17
- Streamlining Event Procedures 3D-Text Wizard-18
- Streamlining Events VBA RGB Color Wizard-19
- Streamlining Events Numbers to Words-20
- Access Users Group(Europe) Presentation-21
- The Event Firing Mechanism of MS Access-22
- One TextBox and Three Wrapper Class Instances-23
- Streamlining Code Synchronized Floating Popup Form-24
- Streamlining Code Compacting/Repair Database-25
- Streamlining Code Remainder Popup Form-26
- Streamlining Code Editing Data in Zoom-in Control-27
- Streamlining Code Filter By Character and Sort-28
- Table Query Records in Collection Object-29
- Class for All Data Entry Editing Forms-30
- Wrapper Class Module Creation Wizard-31
- wrapper-class-template-wizard-v2













No comments:
Post a Comment
Comments subject to moderation before publishing.