8

How can I add "placeholder" text to a Text Box in an Access form?

Before the user has typed anything into the text box I want it to display something like

Name: [Please enter the right name]

and then when the user enters some value the text box should show that instead.

Jota
  • 17,281
  • 7
  • 63
  • 93
JRU
  • 327
  • 2
  • 9
  • 18

3 Answers3

16

Use the .Format property, for text values it will be like this:

@;"Please enter the right name"
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
4dmonster
  • 3,012
  • 1
  • 14
  • 24
0

And if you would like to use like a really placeholder, use conditional formatting. Set the default text color value to gray and if the value is not a "" (empty) set the color to black.

Piszi
  • 1
0

if you want to combine the date and placeholder use format as short Date

and in events vba

Private Sub Form_Load()
If IsNull(Me.VDate) Then
Me.VDate.Format = "@;Date[Blue]"
Else
Me.VDate.Format = "Short Date"
End If
End Sub

Private Sub VDate_AfterUpdate()
If IsNull(Me.VDate) Then
Me.VDate.Format = "@;Date[Blue]"
Else
Me.VDate.Format = "Short Date"
End If
End Sub