If then Else

T

TL

I have written the following If then else statement for a form. It makes
sure that 3 fields in a form add up to a seperate field before I go onto
another procedure. No matter what I do, it keeps skipping over this
statement. I can make sure that the fields add up to [Form].[Text41] one
time and not add up to it another and it still skips it.

Is there a better way of doing this??

If [Form].[Food Cost.SumofTrnValue] + [Form].[Pack Cost.SumofTrnValue] +
[Form].[Labor Costs.TrnValue] + [Form].[Freezing Costs.TrnValue] +
[Form].[Overhead Costs.TrnValue] <> [Form].[Text41] Then
MsgBox "The sum of Food Cost, Pack Cost, Labor Cost, Freezing Cost and
Overhead Cost does not add up to the Total Dollars Field", 0, "Addition
Error"
Cancel = True
frm("Text41").SetFocus
End
End If


Thanks!!

Tim
 
J

Joe Harman

I think your problem is that VBA is looking at these as
string values -- not numbers. Try assigning them to a
variable that has been declared as a numeric then use the
variables in your calculations.

Joe
 
T

Tim Ferguson

What do you mean by normalising?

<gulp />

The last forty years or so of database design and progress is based on an
application of mathematical set theory. The bunch of rules and algorithms
that came out of this research is known as Relational Theory or
Normalisation.

Essentially it's a way of ensuring that the data in a set of tables is
integrated, complete and non-contradictory. Different levels of
implementation are know as First Normal Form, Second Normal Form and so on.
Fully normalised tables maximise the robustness of the data in them.

Anyway, any standard text on basic database design written since the
seventies will explain it much better than I... and there is not room in a
NG for a full tutorial.

B Wishes


Tim F
 

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

Similar Threads

If then Else 1
Are you wasting food? 18
Drowning in Loops 1
Access VBA DCOUNT problem when two forms are involved 0
Table/Forms Design Question 16
Non-Unique value error 7
carry over 1
Suming Fields 4

Top