Date field Problem

  • Thread starter Thread starter Taffy-Taff
  • Start date Start date
T

Taffy-Taff

Hi -
I have a problem and I do not know why.

I have a table called "Outside" with the field name "Field1","Field2"
.... "Field10". The datatype for "Field5" is Date/Time. Some record
have this field blank, while other records have "00/00/00". Then ther
are the records that have nicely formatted dates.

I want to get a total for certain items that meet a particula
condition. Then I want to store the total in a variable then place th
content of the variable in a text box called "Total". I used th
following code to get the total:

' Get total for items coded 11725001 and dated after Jan 1, 2004
totall = DSum("[Field4]", "Delphi Open item Report", "[Field1
= 11725001" And "[Field5] > 1-1-04")

Everything works fine until I added the
And "[Field5] > 1-1-04" section. After adding this section
I am getting a Type Mismatch error. I am surprise because Field5 is
date/time field and 1-1-04 seems to be in a date format. Can you hel
me find out what is going wrong? What effect (if any) does a blan
information in Field5 has on the command? How can I correct it?

I would really appeciate your help.


Taff
 
Taffy,

There are two things wring with your expression. First is your ""s are
not correct... you just need to enclose the entire Where argument of the
DSum function in ""s, and it is incorrect syntax to exclude the word
"and" from the string. Second, a date value must be delimited with ##s
to show it is a date. So, try...
DSum("[Field4]", "Delphi Open item Report", "[Field1]=11725001 And
[Field5]> #1-01-2004#")
 
Back
Top