Problem writing value to text box

  • Thread starter Thread starter jlcts
  • Start date Start date
J

jlcts

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

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

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

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

Back
Top