MS-Access Forms & Report Design Tools are very easy to use and needs only little practice to master them. But creating Controls like the above manualy is very difficult. The above heading with White Border sorrounding the text with Red Color can be created easily with the following Function. Copy and Paste the Code in a Global Module.

 

Note : Before Running this Function ensure that the essential Project Library files that I have mentioned in my earlier Post Command-Button Animation are linked to your Project as well as the Main Programs given under the Topic Create 3D-Headings on Forms are copied and pasted into a Gobal Module in your Project. If not, open that Post and copy and paste the Code into a Global Module in your Project first. Then copy the following code into the same Global Module or in a different one and save it.

Public Function Border2D(ByVal intForeColor As Integer, ByVal intBorderColor As Integer, Optional ByVal Label0Text1 As Integer) As String
'------------------------------------------------------------
'Author : a.p.r. pillai  
'Date : September 2006
'------------------------------------------------------------
Dim intlbls As Integer
Dim j As Integer, ForeColor As Long, BorderColor As Long
Dim lblName() As String, X As Integer, mySection As Section
Dim l As Long, t As Long, intFSize As Integer
On Error Resume Next

Border2D = FormTxtLabels(Label0Text1)
Set mySection = MyFrm.Section(acDetail)
intlbls = mySection.Controls.Count - 1
On Error GoTo Border2D_Err
X = Validate_Dup(MyFrm, 5) ' check type and duplicate
If X = 1 Then
     Exit Function
End If
intlbls = mySection.Controls.Count - 1
X = intForeColor
intForeColor = IIf(X < 0, 0, IIf(X > 15, 15, intForeColor))
X = intBorderColor
intBorderColor = IIf(X < 0, 0, IIf(X > 15, 15, intBorderColor))

ReDim lblName(0 To intlbls) As String  

ForeColor = QBColor(intForeColor)
BorderColor = QBColor(intBorderColor)
For j = 0 To intlbls
   lblName(j) = mySection.Controls(j).NAME
Next
For j = 0 To intlbls
With mySection.Controls(lblName(j))
    .Height = lngheight
    .Width = lngWidth
    .FontName = "Times New Roman"
    intFSize = .FontSize
If intFSize < intFontSize Then
    .FontSize = intFontSize
End If
    .FontUnderline = False
    .TextAlign = intTextAlign
    .BackStyle = intBackStyle
End With
Next
mySection.Controls(lblName(intlbls))
    .ForeColor = ForeColor
For j = 0 To intlbls - 1
     mySection.Controls(lblName(j)).ForeColor = BorderColor
Next
l = intX: t = intY
With mySection.Controls(lblName(4))
    .Left = l
    .Top = t
End With
For j = 0 To intlbls - 1
With mySection.Controls(lblName(j))
If j = 0 Or j = 3 Then  .Left = l - LngI
If j = 1 Or j = 2 Then  .Left = l + LngI
If j = 0 Or j = 1 Then .Top = t
If j = 1 Then .Top = t - (0.0104 * 1440)
If j = 0 Then .Top = t + (0.0104 * 1440)
If j = 2 Then .Top = t + LngI
If j = 3 Then .Top = t - LngI
End With
Next
MsgLabel
Border2D_Exit:
Exit Function    

Border2D_Err:
MsgBox Err.Description,, "Border2D"
Resume Border2D_Exit
End Function

To Run the Function to create the heading text on a new Form, open the VB Module Window (if not already open) by pressing Alt+F11 then press Ctrl+G to open the Immediate Window (Debug window). Type the following text and press Enter.

 

Border2D 15,0

 

The First Parameter is mandatory (Color Value Range 0 – 15) and the 2nd one (Value 0 or 1) is optional. If the Function is called without the first parameter then the Error:

 

‘Compile Error: Argument Not Optional’ will be displayed.

 

The first Parameter 15 is for White Border Color and the Second Parameter 0 stands for Label based Heading (if 2nd Parameter is omitted do not use the coma at the end of first parameter). If 1 is used as 2nd Parameter then a TextBox based Heading is created and text will be placed as a Formula in the Control Source Property.

 

The Module Window will flash a little as if it is refreshed. Minimize the Module Window (with Alt+F11 you can toggle the window) to show up the Database Window and you will see a New Form is Created with the name like Form1 and the Border2D heading is created with a White Border. You can use any color number between 0 to 15. Once the Heading is created you can modify it in several ways.

 

To change the Heading Text, Text Style, Border Color and Text Color:

 

Select all the controls together and display the Property Sheet and change the Caption with the Text of your choice. You can make the Text Bold, Italic or change the Size of the Text. Select a Color from the Color Pallette for Border first. This will change the Forecolor of all Labels. Now Click only on the top Label and apply a different Color for Foreground.

 

–oOo–

 




Download Demo Database


3D Heading Style
Border 3D Heading Style
Shadow 3D Heading Style