NZ, what is Me, Reserved words, AutoCorrect, Compile
---
Hi Katelin,
"What does the "nz" and ",0" do to the equation? "
from Help
'~~~~~~~~~~~~~~~~~~~~~~~~~~``
Nz Function
You can use the Nz function to return zero, a zero-length string ("
"), or another specified value when a Variant is Null. For example, you
can use this function to convert a Null value to another value and
prevent it from propagating through an expression.
Syntax
Nz(variant[, valueifnull])
The Nz function has the following arguments.
Argument
variant
A variable of data type Variant.
valueifnull
Optional (unless used in a query).
A Variant that supplies a value to be returned if the variant
argument is Null. This argument enables you to return a value other than
zero or a zero-length string.
Note If you use the Nz function in an expression in a query without
using the valueifnull argument, the results will be a zero-length string
in the fields that contain null values.
'~~~~~~~~~~~~~~~~~~~~~~~~~~``
the thing to keep in mind when using Nz is what it will return if you
don't the specify the second, optional, argument.
If you are using Nz on a field, it will be the data type of that field
-- 0 for numbers (including dates), and an empty string for text or memo
Unbound textbox / combobox / listbox controls on a form are assumed to
have TEXT in them... so an empty string will be returned if nothing is
specified. And, if you specify something, it doesn't have to be 0 or ""
you could do this:
NZ(..., "no commision is found in the table for this employee")
If you do not specify the optional argument -->
If the expression is bound to a text field, an empty string will be
returned if the field is null. If the expression is bound to a numeric
field, 0 will be returned if the field is null.
it is a good idea to wrap return values from dLookup, etc, in NZ in case
no match was found
.... a good "rule-of-thumb" is to specify the optional arguments (even
though it is not necessary) and do this:
= Nz(DLookup("[Commission]", "Employees", "[EmpID] = " & nz([EmpID],0)),0 )
notice how NZ is used twice -- once to make sure the criteria will be
evaluated, and another time around everything in case dLookup didn't
return a value...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
"Also, what exactly does "Me." mean?"
when you are in the code behind a form or report, Me referes to the form
or report itself. When you type Me. in code, Access will prompt you
with a list of choices so it makes coding easier to use it. Me is not
usually necessary.
It also makes things more clear. If you have Me.Total in code, you know
it is referring to a control named Me. If you just use Total, it could
mean a variable too.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
"...all of their names have changed"
do you mean Names or Controlsource? The ControlSource is what shows up
inside the control itself. To see the name, you can turn on the
Property sheet and look.
the only way the name can get changed is by you.
The controlSource can get changed if you change what it is based on if
you have AutoCorrect on (Tools, Options, General tab). you should, by
the way, disable this.
Failures caused by Name AutoCorrect
http://allenbrowne.com/bug-03.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
"I think it has something to do with the names "
you can check what you are using here:
Problem names and reserved words in Access, Allen Browne
http://www.allenbrowne.com/AppIssueBadWord.html
'~~~~~~~~~ Compile ~~~~~~~~~
Whenever you change code or references, your should always compile
before executing.
from the menu in a module window: Debug, Compile
fix any errors on the yellow highlighted lines
keep compiling until nothing happens (this is good!)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
"...but not in the totalvariance field"
What is the source for your variance control? What is the NAME of the
control with variance in it?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
to help you understand Properties in Access a bit better, send me an
email and request my 30-page Word document on Access Basics (for
Programming) -- it doesn't cover VBA, but prepares you for it because it
covers essentials in Access.
Be sure to put "Access Basics" in the subject line so that I see your
message...
Warm Regards,
Crystal
*

have an awesome day

*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*