date problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created an unbound text box on a form and have a macro set to input
the date when it was last run. The macro 'setvalue' expression linked to the
text box is =date(). The problem is that it returns a date of "December
30th, 1899".... the text box is formatted for a long date. How can I fix this?
 
John V said:
I have created an unbound text box on a form and have a macro set to input
the date when it was last run. The macro 'setvalue' expression linked to the
text box is =date(). The problem is that it returns a date of "December
30th, 1899".... the text box is formatted for a long date. How can I fix this?

First, what does "the date when it was last run" mean and how does that relate
to Date() which is today's date?

Second, what do you mean by "The macro 'setvalue' expression linked to the text
box"? Linked to the TextBox HOW exactly? Macros and code are run in response
to events. What event are you using?

12/30/1899 is the date represented by the number zero so I have to assume that
you are somehow getting a zero entered into a control that is formatted to
display dates.
 
John said:
I have created an unbound text box on a form and have a macro set to
input
the date when it was last run. The macro 'setvalue' expression linked
to the text box is =date(). The problem is that it returns a date
of "December 30th, 1899".... the text box is formatted for a long
date. How can I fix this?

Try =now()
 
The action in the macro is SetValue
The Item is [Forms]![Switchboard]![Text61]
The Expression is =Date()

I've tried =now() as an expression, but that doesn't work either
 
John said:
The action in the macro is SetValue
The Item is [Forms]![Switchboard]![Text61]
The Expression is =Date()

I've tried =now() as an expression, but that doesn't work either

But where is the macro being called? Is there a reason you can't just use a
default value?
 
The macro is set to update information in a table from a server (not done
daily), other information in the table is updated on a daily basis. I need to
be able to show the date on the switchboard that the information from the
server was last updated.

I found a different way to do it using a table and update query with the
query to run in the macro which updates the date to the date it was run. A
subform from the table is then in the switchboard. Now I have an issue with
when the subform is visible. I will start a new thread for that issue.

Thanks for all your input
 
For possible future reference, updating a field with the current date can be
as simple as:
Me.YourDateField = Date
If the update is being initiated by clicking a command button, the code
could be in the command button's Click event.
That would be a VBA procedure rather than a macro. You can still use macros
for a lot of things, but in many cases the VBA procedure is more flexible
and powerful.
 
Back
Top