Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / February 2007

Tip: Looking for answers? Try searching our database.

Problem writing value to text box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jlcts@yahoo.com - 26 Feb 2007 16:12 GMT
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.
Al Campagna - 26 Feb 2007 16:32 GMT
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.
Daniel - 26 Feb 2007 16:33 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.