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!

HELP: validation rule of a text box in a form 1

Status
Not open for further replies.
Nov 6, 2002
89
0
0
CH
Hi there

I need your urgent help.

How can I add a validation rule (preferably "must be bigger than zero) to a text box in a form? Pleaes note that the user cannot fill in any value into the text box since the value in the text box is taken from a query (value in the query field is a formula).

Many thanks for your help. I appreciate any comments.

regards, Stefan

 
Stefan,

Hmm. A validation rule only applies to user input, so you're looking for something different, but I'm not sure what. Maybe you're looking to only display the value if it's between zero and ten? If so, look into the iif statement in help, and you'll be able to make your control display the value or nothing, depending on whether or not the value is in that range.

If that's not what you're looking to do, try explaining it again. I'm sure we'll figure it out.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
The answer to your problem would seem to lie in the creation of an Event procedure triggered by a text box losing its focus.
For clarity here is an example.

I have 2 text boxes , the first [NAME] & the second [DAYS OFF]. The second cannot be modified by the user as the value has been calculated in a query & I assume that you have disabled the control - but it can be tested by a Event procedure when the [NAME] text box loses its focus.

write this code in the private module:
DIM TEMP_STORE AS INTEGER
[DAYS OFF].ENABLED = TRUE
TEMP_STORE=[DAYS OFF].VALUE
IF TEMP_STORE<0 THEN MSGBOX &quot;INVALID DATA&quot; 'or whatever
[DAYS OFF].ENABLED = FALSE

I also assume that you don't want the [DAYS OFF] value
to be less than 0 - so therefore you could set a minimum
or default value by replacing the msgbox command with
[DAYS OFF].Value =1

Hope this helps,
Trystan



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top