Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Put default text into text box without it being stored in the table

Status
Not open for further replies.

TheresAlwaysAWay

Programmer
Mar 15, 2016
135
0
0
US
This is probably easy for the wizards out there, but I'd like to have a value in a text box that says something like "Insert Name Here", preferably in grey, which wouldn't save the words "Insert Name Here" to the underlying table. It's like an information reminder for the user if the field is null.

I hope I explained myself clearly. Is there a way to accomplish that in Access?

As always, thanks in advance.
 
Thank you so much! After playing with the suggestions I made a few modifications.

In the .Format property I inserted the @;”Enter Desired Hint” as your link suggested, but I wanted the hint in grey and default text in black so I made a few other changes.

I set the conditional formatting for the field to the expression IsNull([FieldName]), and set the text to grey under those conditions. Perfect! Almost...

The problem was as I started typing into the field, the conditional formatting didn't recognize the field as other than a null value until after update, so it worked fine, except that as I typed the characters were in grey, and after update they went to black. I didn't like it that way so I did something a little different.

In the OnEnter event I set the value of the field to " " and Refresh if the field value were null. Now that blank field has an invisible blank space in the field, and it's no longer seen as Null. All my typing is in black from that point forward. ALMOST PERFECT!

The last issue is that I didn't want to have the blank leading space saved in my table for search, etc., so on the AfterUpdate event I simply added a Trim([FieldName]). NOW the problem is solved and it works just like HTML. The Trim command also removes the blank space if I remove a value, resetting the field to Null, the text to grey, and causing the Hint Text to reappear!

I couldn't have done it without the help. I've been doing this a long time and still had never seen the Format of @: before.

I always appreciate the willingness of folks here to help others.
 
I had to make one more minor tweak. If I clicked into the field and set the value to " ", and then for some reason didn't do any updating and just went to another field the " " would remain, and since the field was no longer null the Hint text didn't show.

Simple fix. On the OnExit event I used the Trim([FieldName]) command under the condition that the Len([FieldName])=1. That's all. If I try to abandon the field after entering it without an update it will correct itself and still display the Hint text!
 
Great that you were able to modify the link to meet your needs and provide some examples of what you ended up with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top