Has something been written?

P

Proko

I have an unbound text box on a form. I would like to give the user the
opportunity to save the contents of the text box only when something has been
written in it. That is, my save button is not enabled until the length of the
string is greater than zero.
I tried using the key up event with:
if len([mytextbox]) > 0 then
mysavebutton.enabled = true
end if
Can't seem to get it to work though.
I would also like the save button to become disabled again if the user
starts to type something in the text box but then deletes or backspaces all
of what has been written.
Any help would be greatly appreciated.
Proko
 
L

Linq Adams via AccessMonster.com

Use the OnChange event with the Text Property of the textbox. You have to set
the Enabled Property for the MySaveButton to No in the Properties Sheet so
that it starts off Disabled.

Private Sub MyTextBox_Change()
If Len(Me.MyTextBox.Text) > 0 Then
MySaveButton.Enabled = True
Else
MySaveButton.Enabled = False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top