Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date value error...why?

Status
Not open for further replies.

edweberg

Technical User
Feb 23, 2007
11
US
Hi. I'm new at this stuff, so please go easy.
I'm working with Access code created by a worker who left our company. I've narrowed down the problem. This line of code is the problem:

Me.Change_approved_date = Now()

Values when I hover over are as follows:
Me.Change_approved_date = Null
and
Now() = the correct date

In order for the code to run properly, the value of
Me.Change_approved_date has to take on the current date because it's then entered into a table and the code can then carry on. The date in the table remains "null" and then things don't work properly.
This worked fine prior to the new year. Since Jan. 1, 2009 it hasn't been working.

Why will that line of code no longer set Me.Change_approved_date to the correct current date?

Can anyone help point me in the right direction?

Thanks so much.

Erik
 
Are you trying to set a control, field or bound control? If it is a field or bound control then what is the DataType of the field?

RuralGuy (RG for short) aka Allan Bunch MS Access MVP acXP winXP Pro
Please respond to this forum so all may benefit
 
edweberg said:
Values when I hover over are as follows:
Are you checking the values before the line
Code:
Me.Change_approved_date = Now()
has executed (i.e. you have your debug stop exactly on that line)?
Because at that point, the value of Now() has not yet been been assigned to Change_approved_date. You have to let it execute that line (i.e. step over to the next line).

Joe Schwarz
Custom Software Developer
 
How are ya edweberg . . .

Also Note: [blue]Now()[/blue] returns date & time! While [blue]Date[/blue] returns date only. Unless its your intent, [blue]Now()[/blue] could cause problems in date comparisons.

[blue]Your Thoughts . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks everyone for replies. I have to do some digging in order to provide answers to questions.

1) Control, field or bound control. Data type. I don't know. I'll try to figure that out. As I said, I'm working with code written by someone who is no longer here and my own experience with Access and VBA is sketchy.
2) The code does compile. The code runs fine except that where a date is expected, a null value is placed which then causes problems later on. But the code runs just fine.
3) I am indeed checking those values by hovering after the code has stepped over that line.
4) We do want date and time Now()but I'll check with stakeholders and see if date (only) would be adequate.

The perplexing thing is that this application worked perfectly for the last two years, but since the recent new year it hasn't worked. Could the change of year, considering leap year, be messing with assigning a date/time value? The new year and this problem are coincident and do not necessarily have a cause/effect relationship. But it's all I have to go on right now.

A workaround is to go into the table and manually enter a date/time. It lets me do that. Very inconvenient, but it works.

Erik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top