Data Validation

hi there

Registered User.
Local time
Today, 16:30
Joined
Sep 5, 2002
Messages
171
hello everyone,

i have a formatting question i was hoping someone could help me with. i have a couple fields in my table which are of numeric type with data validation ranges assigned to them. the problem is this data is taken during 2 different shifts: night and day. sometimes only the night shift takes data and as such the day shift places and 'X' in the text box. my question is how to i keep numeric type data validation on these fields but allow the user to input a text type ('X') value into the box. is there a simpler solution to my problem. i'm hesitant to add any automation to assign specific values to fields based on a selection of day or night shift because sometimes there might be an 'X' on the day shift for a specific field and a couple days later there might be an 'X' for that same field on the night.

thanks all
 
To allow the entry of any number between 10 and 25, or an "X", set the field's Validation Rule property to:

(= "X") Or (>= 10 And <= 25)
 
Thanks for the response alan. you post makes complete sense and gave myself a big DUH for not thinking of that, but when i tried to implement it and got the "too complicated expression...." error dialog box. i usually see this when trying to pass a numeric value in an expression requiring a text type data or vice versa. is it possible to place a text validation rule within a numeric data type? could you explain a little more?

thanks
 
If the table field's ValidationRule property won't work, you can always go to the form where the users will be adding/editing records, and use the BeforeUpdate event procedure of the text box bound to the field. In that procedure, you can use the IsNumeric function to determine whether text or a number has been entered. If it's text and not "X", or if it's numeric and out of range, display an appropriate MsgBox and set the Cancel argument to True.
 
thanks for the response pat. i thought about using '0' as the default value, but unfortunately i'm afraid it would hurt more than help. the values for this field (text box) are measured, so i don't want to give the illusion that the user took a reading from the monitor and the value was '0'. originally i thought the only way around this was to provide a default value linked to the value of another field (Shift). for example, normally the first shift doesn't record values for 5 fields (controls) on my form; the second shift does this. so, i was thinking to place a default value in those controls when the user selects "first shift" from a combo box. the kicker is that sometimes the second shift might forget to take this value and the first shift will have to do this. its a shame there isn't any syntax for automating people.
 
Thanks for pointing out what I overlooked, Pat: this was a numeric field we were talking about, and so it cannot store an "X". However, the last approach I suggested will work if you change the table field to Text. If you do so, you'll need to always verify that the contents are numeric before attempting any computations using them.
 
i decided to go with default values (Null) and added a little label to identify to the user why those fields in question were blank for a particular shift. for these fields, i'm not interested in performing any calculations on them, but its good to know that aggregate SQL functions omit Null values. i didn't know that. thanks for the help alan and pat.
 

Users who are viewing this thread

Back
Top Bottom