ACC: CreateControl() Function Always Creates Label with ColonID: Q121667
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you use the CreateControl() function to create a text box on a form,
the text box's attached label always contains a colon (:), even if you have
created your own form template and set the AddColon property for the
default text box to No.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information about Access Basic, please
refer to the "Introduction to Programming" manual in Microsoft Access
version 1.1, or the "Building Applications" manual in version 2.0.
Add the following line to the sample code in step 5 of the "Steps to
Reproduce Problem" section later in this article. Insert this line before
the line that reads "DoCmd Restore" to change the label's Caption property
to remove the colon:
MyLabel.Caption=Left$(MyLabel.Caption,Len(MyLabel.Caption)-1).
Microsoft has confirmed this to be a problem in Microsoft Access versions 1.1 and 2.0. This problem no longer occurs in Microsoft Access version 7.0.
Option Explicit
Sub NormalForm ()
Dim MyRecordSource As String
Dim DataX As Integer, DataY As Integer, LabelX As Integer, _
LabelY As Integer
Dim MyForm As String, MyFormCreate As Form, MyLabel As _
Control, MyControl As Control
MyRecordSource = "Table1"
Set MyFormCreate = CreateForm("", "")
MyForm = MyFormCreate.Formname 'Use this line in version 1.1.
MyForm = MyFormCreate.Name 'Use this line in version 2.0.
MyFormCreate.RecordSource = MyRecordSource
LabelX = 100
LabelY = 100
DataX = 1000
DataY = 100
' Create unbound default-size text box in the detail section.
Set MyControl = CreateControl(MyForm, 109, 0, "", "", DataX, _
DataY)
' Create child label control for the text box.
Set MyLabel = CreateControl (MyForm, 100, 0, MyControl.Control_
name, "hello", LabelX, LabelY) 'Use this line in version 1.1.
Set MyLabel = CreateControl(MyForm, 100, 0, MyControl.Name, _
"hello", LabelX, LabelY) 'Use this line in version 2.0.
DoCmd Restore
End Sub
For more information about the CreateControl() function, search for
"CreateControl," and then "CreateControl, CreateReportControl Functions"
using the Microsoft Access version 2.0 Help menu.
Microsoft Access "The Secrets of AccessWizards," version 1.1, Chapter 2,
"Incantations: AccessWizard Functions and Properties," pages 12-15
Keywords : kbusage FmrProp
Version : 1.1 2.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 7, 1999