How to make default value disappear when clicked (1 Viewer)

vent

Registered User.
Local time
Today, 08:26
Joined
May 5, 2017
Messages
160
Hi all

I have a form with various fields and a number of default values (e.g. 'N/A', '000-000-000', etc) How do I make it where once clicked in the box, those defaults automatically disappear rather than highlighting them and deleting?
 

Ranman256

Well-known member
Local time
Today, 08:26
Joined
Apr 9, 2015
Messages
4,339
then dont use Default value.


Montoya:"You keep using that word. I do not think it means what you think it means."
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:26
Joined
May 7, 2009
Messages
19,175
Sre u un continuous form if so look for queing banner on this forum
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:26
Joined
May 7, 2009
Messages
19,175
No, its Queing banner
 

vent

Registered User.
Local time
Today, 08:26
Joined
May 5, 2017
Messages
160
Sorry but I can't find it. Can you direct me?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:26
Joined
Feb 19, 2013
Messages
16,555
rather than using a default value, use the format property for the control and leave the default value empty.

your examples are all strings so for a string you could use

@;[Red]"N/A"

for a number with a null value

0;0;0;[Red]"enter a value greater than 1"

instead of red, you can use a number of alternative colours (the default is black) such as green, blue, yellow
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:26
Joined
May 7, 2009
Messages
19,175
My mistake, cuing banner is for Unbound controls onlyonly.
 

vent

Registered User.
Local time
Today, 08:26
Joined
May 5, 2017
Messages
160
rather than using a default value, use the format property for the control and leave the default value empty.

your examples are all strings so for a string you could use

@;[Red]"N/A"

for a number with a null value

0;0;0;[Red]"enter a value greater than 1"

instead of red, you can use a number of alternative colours (the default is black) such as green, blue, yellow

Hi

So I went into the field Phone Number's format property and did this:
@;[Red]"000-000-0000"
I like how it goes away but when I go into the table where I entered the record, the field phone number is blank
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:26
Joined
Feb 19, 2013
Messages
16,555
what else to you expect? - include a default value you need to change or have it blank if you don't enter anything?

only other thing I can think you can try is to have a bit of code in the control enter event to delete the contents -

e.g. me.txtControl=""

or have you looked at using the input mask property
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 23:26
Joined
Jan 20, 2009
Messages
12,849
This simple procedure selects the contents of the textbox when it is clicked on so that any typing will overwrite what is already in it.

Code:
Private Sub textboxname_Click()
    With Me.textboxname
        .SelStart = 0
        .SelLength = Len(.Text)
    End With
End Sub
It could easily be modified to only select if the value was equal to the default.
 

vent

Registered User.
Local time
Today, 08:26
Joined
May 5, 2017
Messages
160
Thanks guys, my solution was having a default value and setting the onclick property to an event procedure followed exactly what CJ London said and did me.txtControl="".

Thanks!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:26
Joined
May 7, 2009
Messages
19,175
Yes that we'll do on new record, how about you are only browsing and you click the field.
 

Mark_

Longboard on the internet
Local time
Today, 05:26
Joined
Sep 12, 2017
Messages
2,111
Vent,
Something important to remember regarding default values, they should only be used if there is a good reason for it.

NULL is as good a value as any when information is needed. Defaulting a field to '000-000-000' is not only not useful (doesn't really mean anything) but will fill your file with useless information. Better to leave it null rather than putting useless data in.

Defaulting to the most common value is useful, so long as end users understand why. If 90%+ of all transactions are sales, defaulting transaction type to "Sale" makes sense. Only for those cases where it needs to be otherwise do you change it.
 

vent

Registered User.
Local time
Today, 08:26
Joined
May 5, 2017
Messages
160
Vent,
Something important to remember regarding default values, they should only be used if there is a good reason for it.

NULL is as good a value as any when information is needed. Defaulting a field to '000-000-000' is not only not useful (doesn't really mean anything) but will fill your file with useless information. Better to leave it null rather than putting useless data in.

Defaulting to the most common value is useful, so long as end users understand why. If 90%+ of all transactions are sales, defaulting transaction type to "Sale" makes sense. Only for those cases where it needs to be otherwise do you change it.

Thanks for your input Mark. I will rethink this whole approach before I present this project later this month. Thank you.
 

Users who are viewing this thread

Top Bottom