This thread and the answers herein explain the issue well. There are a couple of additional points I'd like to add, which I've found through experimentation:
The order of precedence of the properties is:
.ControlSource
.Value
.Text
From what I've been seeing in Access 2007, if .ControlSource
is undefined when the form opens, .Value
will be Null
.
If you set the .ControlSource
property to =""
(an empty string), that will cause the .Value
property to default to that instead of Null
.
You can set the .Value
property to ""
in the Form_Load
event. But...I've been seeing some erratic operation there; it seems as if .Value
sometimes changes from ""
back to Null
, and I haven't yet worked out the circumstances.
So it seems best to define .ControlSource
to =""
, either in Design View or in the Form_Load
event. But be forewarned, that niblet is tricky because of the embedded double quotes, and it can be tricky to read.
Some ways to do it are:
- myTextbox.ControlSource = "=" & """"" (five double quotes in a row)
- myTextbox.ControlSource = "=" & Chr(34) & Chr(34)
- Etc, etc, there are many ways to do it...
Also, here's an extended tidbit. If you set the .TextFormat
property to Rich Text
, you can format the text in it with bold, italic, colors, etc. But be forewarned (again), beginning with Office 2007, the original Microsoft RTF format was decommissioned in favor of a "mini" version of HTML that only supports a few tags related to formatting fonts and paragraphs.
As an example, say you want the textbox to display the little ASCII checkbox character with the word "valid" in italics next to it, and make it all green. You can do it, but it all has to be in HTML, and it's not easy to read:
myTextbox.TextFormat = acTextFormatHTMLRichText
myTextbox.ControlSource = "=" & Chr(34) & "<font color=#80CA45><font face=Wingdings>" & _
Chr(254) & "</font> <font face=Calibri><i>Valid.</i></font></font>" & Chr(34)