Reset a default value

ECEK

Registered User.
Local time
Today, 13:28
Joined
Dec 19, 2012
Messages
717
I open my form and my textBox1 default value is "Type Name"
Users use this textBox1 to search for clients.

I have a "clear filter" button to reset the form however i can't get the default value of the texBox1 to return to "Type Name". Any ideas?

This is what i have (that doesn't work) on my reset filter command button:
Code:
Private Sub Command99_Click()
Me.Filter = ""
DoCmd.RunCommand acCmdRecordsGoToLast
Me.Refresh
Me.textBox1.DefaultValue = "Type Name"

End Sub
 
The default value only applies to new records, as soon as something is typed in your textbox even though it's unbound you are no longer on a "New" record.

Me.textBox1 = "Type Name"

Will do what you want.
 
use overlapping textbox to have same effect.
add another textbox that overlaps with textbox1, named it txtDummy its value is "Type Here". set the Position of txtDummy to Bring To Front.

on enter event of txtdummy set focus to textbox1.
on exit event of textbox1 set the visible property of txtdummy to true if textbox1 is blank.
for new record set the visible property of txtdummy to true.

Private Sub textbox1_Exit(Cancel As Integer)
Me.txtDummy.Visible = Trim(Me.textbox1 & "") = ""
End Sub


Private Sub Form_Current()
If Me.NewRecord Or Trim(Me.textbox1 & "") = "" Then
Me.txtdummy.Visible = True
End If
End Sub

Private Sub txtDummy_Enter()
Me.textbox1.SetFocus
End Sub
 

Users who are viewing this thread

Back
Top Bottom