date problem

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?
 
R

Rick Brandt

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.
 
J

Joseph Meehan

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()
 
G

Guest

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
 
R

Rick Brandt

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?
 
G

Guest

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
 
B

BruceM

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Access 2007 Macro 1
Connecting Text Box in Query Criteria 4
Date Difference 5
date value 3
Date Range on Report 6
Enter Parameter Value Date 2
Combine date and tim 1
DateAdd problem 1

Top