Iif Form To Table

I

Irwin109

Hi
I have a problem, I am using a form for Data Entry on my database and a few
of the input boxes have Iif statements in them, which (after I messed around
a little) work fine, however when viewing the table that the data saves to,
none of the Iif functions "results" are inputted... Is there a way to keep
the Iif function and have it save the "result" to the table?

If I need to make it a little clearer please say so!!!
 
M

Marshall Barton

Irwin109 said:
I have a problem, I am using a form for Data Entry on my database and a few
of the input boxes have Iif statements in them, which (after I messed around
a little) work fine, however when viewing the table that the data saves to,
none of the Iif functions "results" are inputted... Is there a way to keep
the Iif function and have it save the "result" to the table?


The first rule to use in answering your question is:
If a value can be calculated from values stored in tables,
then the calculated value shoulf NOT be stored in a table.
Instead, the value should be recalculated whenever you need
to use or display it.

If the value can not be calculated from values in tables,
then you should think real hard about your tables. Maybe a
more complete set of tables can eliminate the need to save
the calculated value.

In some situations, a calculated value really does need to
be saved. In these cases, you have to use VBA code to
calculate the value and put the value in a bound control on
the form. Where you put the code depends on the
calculation.
 
I

Irwin109

I see what you are saying! So my best bet is to create a query/form/report to
display the values rather than the table itself... Thanks for the help I'll
get to work on it right away!
 
T

Tom van Stiphout

On Wed, 15 Apr 2009 06:16:05 -0700, Irwin109

It appears that would not be necessary. Say you have an expression
like this:
=IIf(Me.txtFirstName='Tom', 'Good', 'Bad')
You might say: how can I save Good or Bad in some database field?
I say: not needed. This is a "calculated value" and those don't belong
in a database. Rather if you ever need it again, recalculate it in a
query:
select FirstName, IIf(Me.txtFirstName='Tom', 'Good', 'Bad')
from myTable
Why is my way better? Consider the situation where someone updates the
table's FirstName field, but forgets to update the GoodBad field.

-Tom.
Microsoft Access MVP
 

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