Question : Data Validation

I need to find out how to validate date in the following scenario.

I have a set of numbers (1 to 10) that need to be entered into a field  there are two sitpulation though, 1) They must be one of the numbers 1 to 10 and 2) they need to be unique. That is once number 1 has been used it cannot be used again.

There are 10 fields that need to have information in them and each one has to be unique and each one must have one of the numbers 1 to 10.  

Any ideas? I am stumped after trying about 10 different ways.

Thanks

GA

Answer : Data Validation

Create a function in the FORM DECLARATION

Function BadData() as boolean
dim vArray(10) as integer
dim vArrayCnt as integer
dim vj as integer
dim vabort as boolean
dim vVal as integer

if not isnull(me.field1) then
     vVal = me.field1
     gosub checkval
     if vabort = true then goto funcout
end if

if not isnull(me.field2) then
     vVal = me.field2
     gosub checkval
     if vabort = true then goto funcout
end if

'--- copy and paste for each additional field


funcout:
baddata = vabort

exit function

CheckVal:
    If vVal < 0 and vVal > 10 then
          vabort = true
    else
         for vj = 1 to vArrayCnt
              if vVal = vArray(vj) then
                   vabort = true
                   exit for
              end if
         next vj
         if vabort = false then
              vArrayCnt = vArrayCnt + 1
              vArray(vArrayCnt) = vVal
          end if
     end if
return
======================================


You could loop through all the controls on the form instead of copy and paste the routine 10 times.

Scott C
Random Solutions  
 
programming4us programming4us