Progressive Calculations

D

DubboPete

Hi all,

I have three fields on a form. Dose1, Calc1 and Calc2.

Dose1 will be the field into which a numerical entry will be made, and
this entry will always be an even number. It's based around a
prescription drug which comes in either 8mg tablets or 2mg tablets,
and a combination of both tablets can be used to make up a dose.

Example: a 22mg prescription dose would consist of 2 x 8mg tablets
(16mg), pls 3 x 2mg tablets (6mg), that's 5 tablets in all amounting
to 22mg. I'd like to know how to calculate the following:

If Dose1 = 22 then Calc1 should be 22 divided by 8 (as a whole number
rounded down) = 2
If Calc1 is 2, then Calc2 should be (Dose1 (22) minus Calc1 (2x8))
divided by 2 = 3
(Dose1-Calc1)/2

'or'

8 goes into 22 twice, with the remainder of 6, so Calc1 is 2...
The 'remainder of 6' is then divided by 2, so Calc2 is 3...

That would then split the dose to 2 x 8mg tablets plus 3 x 2mg
tablets, a total of 22mg.

Not a clue how to update Calc1 and Calc2 depending on the entry in
Dose1. Anybody got any ideas?

thabnks in anticipation

DubboPete
 
D

DubboPete

Hi all,

I have three fields on a form.   Dose1, Calc1 and Calc2.

Dose1 will be the field into which a numerical entry will be made, and
this entry will always be an even number.  It's based around a
prescription drug which comes in either 8mg tablets or 2mg tablets,
and a combination of both tablets can be used to make up a dose.

Example: a 22mg prescription dose would consist of 2 x 8mg tablets
(16mg), pls 3 x 2mg tablets (6mg), that's 5 tablets in all amounting
to 22mg.   I'd like to know how to calculate the following:

If Dose1 = 22 then Calc1 should be 22 divided by 8 (as a whole number
rounded down) = 2
If Calc1 is 2, then Calc2 should be (Dose1 (22) minus Calc1 (2x8))
divided by 2 = 3
(Dose1-Calc1)/2

'or'

8 goes into 22 twice, with the remainder of 6, so Calc1 is 2...
The 'remainder of 6' is then divided by 2, so Calc2 is 3...

That would then split the dose to 2 x 8mg tablets plus 3 x 2mg
tablets, a total of 22mg.

Not a clue how to update Calc1 and Calc2 depending on the entry in
Dose1.   Anybody got any ideas?

thabnks in anticipation

DubboPete

Don't worry guys, I fixed it...

me.calc1 = Fix(me.dose1 / 8) = 2 ' 8mg tablets
me.calc2 = (me.dose1 - (me.calc1 * 8)) / 2 = 3 ' 2mg tablets
 
J

John W. Vinson

Don't worry guys, I fixed it...

me.calc1 = Fix(me.dose1 / 8) = 2 ' 8mg tablets
me.calc2 = (me.dose1 - (me.calc1 * 8)) / 2 = 3 ' 2mg tablets

It's obscure but it's actually a bit easier than that: you can use the integer
divide operator \ instead of combining Fix and the division operator /:

me.calc1 = me.dose1 \ 8
me.calc2 = (me.dose1 MOD 8) / 2
 

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