It can be done, but it takes a lot of work and code, because of the events June7 mentioned! And it can only really be done for a Single View Form.
- Delete the Textbox’s attached Label
- Create new Label for Textbox
- Name the new Label something appropriate
- Enter your Caption for the new Label
- Set BackStyle and BorderStyle to Transparent
- Position the Label in the Textbox
Now, use this code
Code:
Private Sub Form_Current()
If Nz(Me.TargetField, "") <> "" Then
TargetFieldLabel.Visible = False
Else
TargetFieldLabel.Visible = True
End If
End Sub
Private Sub TargetField_GotFocus()
TargetFieldLabel.Visible = False
End Sub
Private Sub TargetFieldLabel_Click()
TargetField.SetFocus
End Sub
Private Sub TargetField_LostFocus()
If Nz(Me.TargetField, "") <> "" Then
TargetFieldLabel.Visible = False
Else
TargetFieldLabel.Visible = True
End If
End Sub
And this has to be done for each Textbox!
If the Form is Unbound, you can omit the Form_Current event.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007