Trying to get percentage from VBA

G

Guest

Can anyone tell me what I am doing wrong here to figure
percent? I tried to use all sorts of declrations but
cannot figure it out. Code is below

Private Sub SampleWeight_AfterUpdate()

'After the weight has been entered, figure the
percentage off (+/- 10)
x = Me.SampleWeight.Value
y = Me.Text156.Value
Tolerance = (x - y) / y
If Tolerance > 10 Then
Me.Text154.Value = "The percentage is over 10% ( "
& Tolerance & "% )"
ElseIf Tolerance < -10 Then
Me.Text154.Value = "The percentage is under 10%
( " & Tolerance & "% )"
Else
Me.Text154.Value = "The weight is within
specification"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top