Calculated field in forms

  • Thread starter Thread starter Jeffrey
  • Start date Start date
J

Jeffrey

I'm trying to calculate a value in a form from 2 fields
in my table and assign that value to a field in the table.

The 3 fields are:
# RX Meds
Scheduled
PRN

The user will enter # Rx Meds, and Scheduled. From that,
I want to calculate PRN and display it.

I tried putting PRN:[# Rx Meds]-[Scheduled] in the
controlsource but I keep getting #name?

How can I calculate this value and assign it to the PRN
field?

Thanks

Jeff
 
You don't store the value of any calculations

When you retrieve the data using a query, form or report you simply use the
formulae.

For example on a form to display the details you could set the control
source of the PRN field to be

=[txtRxMeds]-[txtScheduled]
 
Thanks for the reply. I realize that it is not the best
use of a relational database, but can it be done, and how?

Jeff
-----Original Message-----
You don't store the value of any calculations

When you retrieve the data using a query, form or report you simply use the
formulae.

For example on a form to display the details you could set the control
source of the PRN field to be

=[txtRxMeds]-[txtScheduled]





Jeffrey said:
I'm trying to calculate a value in a form from 2 fields
in my table and assign that value to a field in the table.

The 3 fields are:
# RX Meds
Scheduled
PRN

The user will enter # Rx Meds, and Scheduled. From that,
I want to calculate PRN and display it.

I tried putting PRN:[# Rx Meds]-[Scheduled] in the
controlsource but I keep getting #name?

How can I calculate this value and assign it to the PRN
field?

Thanks

Jeff


.
 
Jeffrey said:
Thanks for the reply. I realize that it is not the best
use of a relational database, but can it be done, and how?

Jeff

It would be done with Me!PRN = Me![txtRxMeds]-Me![txtScheduled]
placed in the beforeupdate event for the form.

While there are times when doing this is legitimate it would be a serious
mistake in this case.
I'm assuming this is a medical program and possibly one that deals with
prescriptions.
These records, once entered, are *never* supposed to be changed. Any change
should, legally must, generate a new record.(Not that my pharmacy program
doesn't have a backdoor to allow this.)

Use the calculation.
-----Original Message-----
You don't store the value of any calculations

When you retrieve the data using a query, form or report you simply use the
formulae.

For example on a form to display the details you could set the control
source of the PRN field to be

=[txtRxMeds]-[txtScheduled]





Jeffrey said:
I'm trying to calculate a value in a form from 2 fields
in my table and assign that value to a field in the table.

The 3 fields are:
# RX Meds
Scheduled
PRN

The user will enter # Rx Meds, and Scheduled. From that,
I want to calculate PRN and display it.

I tried putting PRN:[# Rx Meds]-[Scheduled] in the
controlsource but I keep getting #name?

How can I calculate this value and assign it to the PRN
field?

Thanks

Jeff


.
 
Mike,

Thanks....I tried it but nothing happens...although I
don't get the error message. BTW..my fields are [PRN],
[# Rx Meds] and [Scheduled]. I'm not sure how the "txt"
got put in in the previous reply.

So, I put:
Me!PRN=Me![# Rx Meds]-Me![Scheduled]
in the Before Update event of the textbox where PRN is
the control source. Is that what you suggested?

This program is being used in a retrospective medical
research study so the compliance issue doesn't exist as
long as we don't maintain anything that can identify the
patient.

Jeff
-----Original Message-----

Jeffrey said:
Thanks for the reply. I realize that it is not the best
use of a relational database, but can it be done, and how?

Jeff

It would be done with Me!PRN = Me![txtRxMeds]-Me! [txtScheduled]
placed in the beforeupdate event for the form.

While there are times when doing this is legitimate it would be a serious
mistake in this case.
I'm assuming this is a medical program and possibly one that deals with
prescriptions.
These records, once entered, are *never* supposed to be changed. Any change
should, legally must, generate a new record.(Not that my pharmacy program
doesn't have a backdoor to allow this.)

Use the calculation.
-----Original Message-----
You don't store the value of any calculations

When you retrieve the data using a query, form or
report
you simply use the
formulae.

For example on a form to display the details you could set the control
source of the PRN field to be

=[txtRxMeds]-[txtScheduled]





I'm trying to calculate a value in a form from 2 fields
in my table and assign that value to a field in the table.

The 3 fields are:
# RX Meds
Scheduled
PRN

The user will enter # Rx Meds, and Scheduled. From that,
I want to calculate PRN and display it.

I tried putting PRN:[# Rx Meds]-[Scheduled] in the
controlsource but I keep getting #name?

How can I calculate this value and assign it to the PRN
field?

Thanks

Jeff


.


.
 
Back
Top