Report Function

C

Caroline

I need to creat a function that will count the number of
blank fields between entries in a table. I could have a
record with all fields filled in the next record the Name
Field is blank, the next line the name field is blank,
then the next line the name field is filled.

I need to create a function that counts the number of
lines that are blank for the Name field something like:

counter = 0
Iif ([fldName] is null,
counter=counter+1,counter=counter+0)

then I needit to loop so it counts the 2 blank fields
listed in the example above. I am having a problem
defining the public function for use in this report. Any
guidence would be helpful.

Caroline
 
J

Jeff Boyce

Caroline

You haven't indicated your data structure, nor to what purpose you'll put
knowing how many blanks there are. This information could help folks offer
more specific suggestions.

One approach might be to run a query against the table that counts the
number of rows in which the name field is null. By the way, MS Access
treats the word "Name" as a reserved word -- if you are using it as the name
of your field, you and Access will both be confused.
 
P

Paul Johnson

I have been working with an existing data structure (not my choice) that has
been using "Name" as a field name in a table, and although it has given me
some baffling moments, and I have had to be careful to refer to it
explicitly when referencing it, it has not been an impossible situation. If
you have the choice to change the name, you should, but if (as in my case)
the structure was already in use you can't change it, you will be able to
survive.

Assuming you do the fix Jeff indicates, changing the field name to
"strName," for example, then you could use this statement to find the number
of records with null values for the strName field:

dCount(1,"MyTable", "strName is Null")

Using a constant dummy value (like 1) for the first parameter is necessary
in this case, because if you ask the dCount to return the count of
"strName," it will only return the count for records where strName holds
non-null values, which will conflict with the Where expression "strName is
Null."

In other words, dCount("strName","MyTable", "strName is Null") always
returns zero.

HTH
Paul
 
Top