Should be simple

  • Thread starter Thread starter Maltese
  • Start date Start date
M

Maltese

Guest
G'Day:

I am working on a simnple form that has just a few simple calculations in it. One being wieght difference and the other being percentage weight difference.

I get Access to calculate the wieght difference easily, but Ican't then get it to calculate a percentage weight difference (in another cell).

This is what I have down for code.

If Weigh1 <> 0 Then
WeightDiff = Weigh1 - Weigh2
End If
If WeightDiff <> 0 Then
PerWeightLoss = WeightDiff / Weigh1
End If

Any Suggestions?

Thanks
 
I don't see why that wouldn't work, offhand. What error do you get? Double check the control names.
 
response

I am not getting error messages, it just is not computing the answer. I have looked at the settings for the table and the fields in the form and can not find anything there.

Thanks
 
In which event are you firing the code?
 
Have you put in a breakpoint and checked the values? Can you post a sample db?
 
Sorry I just getting back in the office

I put the code in the AfterUpdate part of the field.

I have been able to get the first part of the code to work - the weigh1 return.

It is the second part of the code I am having problems with - figuring the PerWeightLoss.

I have attached a sample dBase and the frm in question is frm Weight2 and the code is located on the Weight field.

Thanks for your help.
 
Last edited:
Why not just put the calculation in the control source of the two text boxes?

WeightDiff control source.....
=[Weigh1]-[Weigh2]

PerWeightLoss control source.....
=[WeightDiff]/[Weigh1]
 
Thanks

That works great - I never thought of that. I appreciate all of your help!
 
Wellll - I guess it isn't working

I thank You for your patience - I guess I have this more messed up than I thought.

When I change the Control Source to the equations - I get the correct calculations, but I need to be able to save that information in my table.

I am trying to post a sample dBase for your reference.

Thanks for your help.
 

Attachments

You shouldn't need to store calculated values. If you are going to print a report, you can put in the same equations you put in the form text boxes. Do you have specific purpose for having the calculated values in the table itself?
 
Your problem is that PerWeightLoss in the Participants table has a data type of long integer, which won't hold a decimal value (like a percentage). You'd need to change it to a type that will hold decimals.

Having said that, since the percent can always be calculated from other data, it should not be stored. For that matter, the difference should not be stored either. Both can be calculated from the 2 weight readings.

Edit: sorry vangogh, I started responding and got distracted. By the time I finished and posted, you had answered.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom