2 questions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

1. I have a calculated value field on a form. ( =[BillableHours]
*[HourlyRate]). The calculation works fine. But how do I save the answer in a
table [Invoices] ?

2. I have a subform [ProjectIDMaster] on on main form [InvoiceInput]. The
subform has 3 fields from table [ProjectIDMaster]. I can scroll through all
of the records on the sub form which is what I want to do. How can I get the
record that I select to save into the main forms table [Invoices].

Thank you!!
 
Answer to both questions is - Don't.

A table is used to store unique data.
tblPeople [1stName],[Surname],[DateofBirth], etc.
It is NOT a good idea to store calculated values.
ie. from the date of birth field you can work out that "as of today" what a
person's age i
=DateDiff("yyyy",[DateofBirth],Date())-IIf(Format([DateofBirth],"mmdd")>Format(Date(),"mmdd"),1,0)
BUT this information will be different tomorrow so why store it unless you
want to know their age every day from now until you delete your D Base. Why
not just get it as and when you need it (on a form to view or in a report to
distribute it).

Your question regarding ( =[BillableHours] *[HourlyRate]) is the same. The
[BillableHours] is data and so is [HourlyRate] but the result of (
=[BillableHours] *[HourlyRate]) will be different each time you run the
calculation if you input new hours or rates. If these are always the same
you don't need a calculation to work it out.
As for your [Invoices] if you REALLY NEED a hard copy then you can save the
results of any calculation (setvalue) but why do it. It just un-unique data.
Some people export invoices to word and save them in other formats. But best
bet is simply not to.
As you can always re-run the calculation whenever you need to.

Sorry if it's not what you wanted but ( in "most circumstances") it really
isn't a good idea.
 
Jason,

1. Although Wayne is correct that calculated fields should normally be
calculated on the fly, this may be one of the rare circumstances he mentions
where you should, depending on where HourlyRate is coming from.

If it is stored in the table along with each BillableHours record, then you
should calculate it on the fly. However, if it is a field from say, an
Employee table that you are *displaying* on the form, either by basing it on
a query linking Employee to your InvoiceDetail table, or by using the Column
property of an Employee combo box, you will want your Invoice table to
capture the currrent value of HourlyRate, since, like Death and Taxes, it
going up eventually is one of life's certainties.

2. A main form and subform are generally used to display a one-to-many
relationship. In your case, the Project (one side) and the Invoices (many
side) are reversed. If your main form was based rather on Projects, and
linked to Invoices by the ProjectID, the form would automatically display all
the invoices associated with the currently selected Project record, and would
automatically enter the ProjectID into any new record.

Hope that helps.
Sprinks
 
Back
Top