Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB code to fill date and time in table row

4 views
Skip to first unread message

AA Arens

unread,
Jun 13, 2006, 11:28:41 AM6/13/06
to
A)
I have a button on my form. By a push, I want to fill present date and
time in the two rows of the table.

Form Name: Company
Table Name: Company
consists Company ID as primary key, and other company related info,
name, phone number, and Date and Time (all separate rows)

B)
WHen I push again, or I access the same record on my form again, and
activate the button, it replaces the ols Date and old Time with the new
ones, so, it overwrites.

What is the VB code for A and B?
I guess must be placed in "On Click".

Bart
Access 2003

Keith Wilby

unread,
Jun 13, 2006, 11:44:12 AM6/13/06
to
"AA Arens" <bartva...@gmail.com> wrote in message
news:1150212521....@p79g2000cwp.googlegroups.com...

First off, don't use "Date" or "Time" for field names as they're reserved
words in Access. For my example I've assumed control names are "txtDate"
and "txtTime" bound to your date and time fields.

Create a command button and out this in its on click event:

Me.txtDate = Date
Me.txtTime = Time()
Me.Refresh

HTH - Keith.
www.keithwilby.com


Arno R

unread,
Jun 13, 2006, 12:31:31 PM6/13/06
to

"AA Arens" <bartva...@gmail.com> schreef in bericht news:1150212521....@p79g2000cwp.googlegroups.com...

Look at the answer that Keith gave you for the solution, but ...
-- what do you want to achieve?
-- why recording the date and time?
If you want the date and time recorded when the record has changed you simply use the forms' afterupdate-event.
If you want the date and time recorded when the record is viewed you simply use the forms' oncurrent-event.
(Same code as Keith gave you)
No need to click any button maybe...
But you may have your reasons to use a button...

Arno R

Bob Quintal

unread,
Jun 13, 2006, 4:06:38 PM6/13/06
to
"Arno R" <arraNO...@tiscali.nl> wrote in
news:448ee86b$0$2013$ba62...@text.nova.planet.nl:

> If you want the date and time recorded when the record has
> changed you simply use the forms' afterupdate-event.

Use the ***BeforeUpdate*** event, not AfterUpdate.

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

AA Arens

unread,
Jun 14, 2006, 11:32:12 AM6/14/06
to
It works, it must be Me! instead of Me.

The reason why I wanted the descried question, is:

I do have a Note (memoblock) on my form and every time there is any
progression/ modification, we have to push on the date-insert button,
which insert "(date) ----" at the end of the memo block xontents,
before we fill in some text.
Together with the date insert action, I added date and time for the
combo-box. Now the most recent modifed records are on top of the list
since I order by date and time. Without the insert date in the memo
block, the record is not considered modified.
See the discission on
http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/e1190eba19e4e62f/4f8340fa64437ede?lnk=st&q=aa+arens&rnum=2#4f8340fa64437ede


Thanks to all.

Bart

Arno R

unread,
Jun 14, 2006, 12:56:21 PM6/14/06
to

"Bob Quintal" <rqui...@sPAmpatico.ca> schreef in bericht news:Xns97E1AD909...@66.150.105.47...

> "Arno R" <arraNO...@tiscali.nl> wrote in
> news:448ee86b$0$2013$ba62...@text.nova.planet.nl:
>
>> If you want the date and time recorded when the record has
>> changed you simply use the forms' afterupdate-event.
>
> Use the ***BeforeUpdate*** event, not AfterUpdate.
>

Yep, you are right Bob. Sorry for the mistake.

Arno R

Keith Wilby

unread,
Jun 15, 2006, 3:18:38 AM6/15/06
to
"AA Arens" <bartva...@gmail.com> wrote in message
news:1150299132....@f6g2000cwb.googlegroups.com...

> It works, it must be Me! instead of Me.
>

"Me." will work if you're referencing a text box name. What error message
do you get?


AA Arens

unread,
Jun 16, 2006, 11:56:05 AM6/16/06
to
Comile Error: Method or data member not found

Bart

AA Arens

unread,
Jun 16, 2006, 12:57:45 PM6/16/06
to
If I use

Me.txtDate = Date
Me.txtTime = Time()
Me.Refresh

In BeforeUpdate, the Refreh command is fault.
Beside that, the record is not considered modifed when I type some text
in the Notes. There is not add of date and time, when the Refresh is
disabled (').

Let's look at this:
When I approach a record, is it possible to have it considered modified
(date and time added) when I view-only the record a minimum of seconds?
Because I want to have also a recently modifed record when I only
approach it (to look for the contents). But a minimum of x seconds,
otherwise all records will be considered modifed when I navigate though
the records!


Bart

Rick Wannall

unread,
Jun 16, 2006, 2:07:45 PM6/16/06
to
If you take off the Me.Refresh your code will probably work. You shouldn't
rely on some number of seconds before counting whether a record is edited or
not.

When you're in the middle of a data writing sequence, as you are when you
fire off BeforeUpdate, don't attempt form- or recordset- level operations.
You are bumping into the write sequence.

0 new messages