On-Click Clear

JD316632

Registered User.
Local time
Today, 11:37
Joined
Jun 9, 2009
Messages
17
I've searched Google but to no avail (maybe I'm not not being specific enough) but I have a form with a textbox with a default value of "Input # Received" and an input mask for a 3 or 4 digit number, what I would like to have is when a user clicks the textbos the "Input # Received" clears and the input mask is displayed.

Any help is greatly appreciated.
 
IMHO, the reason you have having trouble find out how to do this is because it is not normally done in Access. It may be possible, but it may also not be very easy with the built in controls. There may be a third party control that you can purchase does it.

Hmmm... as I think about this, I may have an example that is close to what you want. Let me do a little digging in my code archive and see what I find ...
 
IMHO, the reason you have having trouble find out how to do this is because it is not normally done in Access. It may be possible, but it may also not be very easy with the built in controls. There may be a third party control that you can purchase does it.

Hmmm... as I think about this, I may have an example that is close to what you want. Let me do a little digging in my code archive and see what I find ...


Any help is greatly appreciated, in the end I just want it so it has default text displayed, and once they click to type in the # received it clears that text out.
 
What you want is something like you see done in web pages when you are filling out a form or search boxes. Is that correct?

The closest thing I have is something that works for a combo box.

Check out:
ComboBox trick like on web pages

Is this what you want?
 
What you want is something like you see done in web pages when you are filling out a form or search boxes. Is that correct?

The closest thing I have is something that works for a combo box.

Check out:
ComboBox trick like on web pages

Is this what you want?

Not quite, let me try explaining a little better.

I have a text box that I want to enter a numerical value in, however for the default value I have it so it shows "Input # Received". So when the database is first opened or the form is reset the text box shows "Input # Received". When someone clicks on that box I would like for it to clear the box so they can type in the total received and not have to backspace the default text out first.
 
I do understand what you want to do. I just have never seen it done an database type applications that are not web based.

I have never tried to do what you want, but I would use the On Enter event, not the On click event. Since a user can normally get to a text box not just only by clicking, but also tabbing. Using the On Enter event will "fire"no matter how the user gets the focus to the text box.


*** This is untested "Air Code" ***

try something like:

Code:
Private Sub txtReceived_Enter()

 If Chr(34) & Me.txtReceived.Value & Chr(34) = Me.txtReceived.DefaultValue Then
    Me.txtReceived = Null
 End If


End Sub

** Note: Assuming that the text box control is named txtReceived. You will need to change it to your actual text box name.


If it were me doing this for a database, I would NOT be using the default value for this. I would do something similar to the example I gave you. I could be wrong, but I suspect that using the default value in this way could cause other issues. I would urge you to do lots of testing and have really good error handling code and data validation code in the form's before update event.

Be sure to make lots of backups. Hope your database is split and you are using a test back end!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom