validate data (subform)

  • Thread starter Thread starter Brahim
  • Start date Start date
B

Brahim

Hi

i have a subform wich is used to insert Percentage of an
activity, what i want is to prevent user to insert
something greater or less than 100%!!! (sum(Activity
Percent) should be 100%

Exemple:

Activity Code | Activity Desc | Activity Percent

01 | Programmer | 75%
02 | Analyst | 25%


------------------------>SumPercent = 100%

what i did on the ActivityPercent_exit i put the code to
check the sumPercent but this one is not updated yet, bcoz
we need to go to next record to get SumPercent updated

any idea how to solve this issue

please this is very urgent

thanks in advance
 
You cannot force the sum to be 100%, and still allow the user to enter
multiple records. They would have to enter 100% on the first record (to
achieve the 100% goal), and then could only enter 0% on subsequent records.

You could automatically offer the remaining percentage when the user starts
a record by using the BeforeInsert event procedure of the form like this:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[Activity Percent] = 1 - Nz(Me.SumPercent, 0)
End Sub
 
Back
Top