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!

ensure text is entered in a field 1

Status
Not open for further replies.

SimonCleaver

IS-IT--Management
Jun 2, 2003
16
0
0
ES
Hi - sorry if this is a dumb question but it has got me stumped.
I have a field in a table (and also on a form from this table) for a "Description".
I want to ensure that some text is entered in this field by a user.
I tried the "Required" property set to yes - but the error message that pops up if text is not entered is a bit "non user-friendly"
What I am trying to do is either; change the error message text - or should i use the Validation property to ensure text is entered.
If I use the validation property method what is the code to ensure text is entered - i tried Like "" but it allowed a user so save a record that did not have any text entered.
Thnaks for any help or advice given.
 
Within your table set the Required property to False and the Allow Zero Length to True. Then add a validation rule Is Not Null And <> &quot;&quot; and add some Validation Text in your nice user-friendly form. This has the same effect as setting Required True and Allow Zero Length False but provides your custome message if the rule is broken i.e. either a null or zero-length string is entered.

Unfortunately the Required property is tested before all other validation rules/form processing and will pop up the default Access message. You don't get a look in.
 
Where You validate the txtbox value query it like this:

If Len(Nz(txtbox))=0 then

If its true nothing vas entered.

If Your txtbox needs a number in the AfterUpdate say this

if Isnumeric(FormatNumber(Nz(txtbox),2))=0 then txtbox=&quot;&quot;

Check out the IsNumeric and the FormatNumber functions.

If You don't want to validate on the form then save the data in Your table like this:

rst![Field]=iif(FormatNumber(Nz(txtbox),2))

If the entered text it's not number the saved value will be 0
 
Sorry

rst![Field]=FormatNumber(Nz(txtbox),2)

By the way...where You validate the data?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top