I just want to write the date/time to a text box.
dim thetime as string
thetime = Now
[Forms]![frmexample]![when changed] = thetime
me.When_changed = thetime
Me.When_changed.Value = thetime
Me.When_changed.Text = thetime
It always fails trying to save the record. I'm also trying to save a
global variable to a text box and that fails with the same error.
I know I can open the recordset, find the current record and change
that field. But I remember doing it this way somehow and it's much
simpler thanks.
jlcts,
You wrote...
>It always fails trying to save the record.
How does it fail? Do you get an error message? If so... what would that be?
First, is the field [When Changed] a "bound" field?
By that... is the ControlSource of [When Changed] on the form, a Date/Time field from
your table?
If so, then...
'Upon some action or event...
Me.[When Changed] = Now() '(Now = current Date and Tme)
'(Date = current Date)
You also wrote...
> dim thetime as string
Date and Time fields are not Strings, they are Date type. But, since it should not be
necessary to Dim anything to update the value of [When Changed], that's a moot issue.
Just be aware of that...

Signature
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions
"Find a job that you love, and you'll never work a day in your life."
>I just want to write the date/time to a text box.
>
[quoted text clipped - 12 lines]
> that field. But I remember doing it this way somehow and it's much
> simpler thanks.
The following work fine for me
Dim dtDateTime As Variant
dtDateTime = Now()
Me.When_changed = dtDateTime
if it does not work for you then I think you need to look at your table
design for that field. Is is properly formatted as a Date Type = "Date/Time"?
Daniel P
> I just want to write the date/time to a text box.
>
[quoted text clipped - 12 lines]
> that field. But I remember doing it this way somehow and it's much
> simpler thanks.
jlcts@yahoo.com - 26 Feb 2007 17:19 GMT
[When changed] is bound to a table as a date/time field, with general
date/time as the format.
me.when_changed = now()
didn't work. when i went to a different record (by clicking a list
box) i got
error 2001 "you cancelled the previous operation"
on the line "Me.Bookmark = rs.Bookmark"
this is the silliest problem ever.