Date error

  • Thread starter Thread starter APH
  • Start date Start date
A

APH

Hi in some VB code I have the following:

If IsNull([Date]) Then [Date] = Date

I want to just have the current date without the time. I tried Date() at
the end, but VB is removing the ().

My code is not workon. Can someone tell me what I am doing wrong please?

thanks

Alex
 
APH

What's NOT WORKING? Is there an error message?

Also you should IMMEDIATELY change your field name from Date (which is a
reserved word) to anything else (Rumplestiltskin would be better, but the
kind of date like StartDate or DueDate would get you out reserved word hell
and be more descriptive to boot), or at the minimum alias it in the query
that is the data source for your form.

Ron W
 
Have you tried stepping through the code to see what is happening? Does the
If statement fail because it doesn't think that your field is Null or does
the value assignment fail?

Yes, Access will remove the trailing () in the code window, but will require
it in controls and queries. Also, as Ron suggested, change the field name to
something that isn't a Reserved Word. A reserved word is something that
Access uses as a built in item. In this case, it is the Date() function.
 
Thanks guys - think i need a holiday - I had the field names set Ok but had
changed the object name to Date for some reason. Its Ok now - thanks

Alex
 
Back
Top