473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

VB code to fill date and time in table row

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

Jun 13 '06 #1
9 3709
"AA Arens" <ba***********@gmail.com> wrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
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


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
Jun 13 '06 #2

"AA Arens" <ba***********@gmail.com> schreef in bericht news:11*********************@p79g2000cwp.googlegro ups.com...
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


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
Jun 13 '06 #3
"Arno R" <ar***********@tiscali.nl> wrote in
news:44**********************@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

Jun 13 '06 #4
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....8340fa64437ede
Thanks to all.

Bart

Bob Quintal wrote:
"Arno R" <ar***********@tiscali.nl> wrote in
news:44**********************@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


Jun 14 '06 #5

"Bob Quintal" <rq******@sPAmpatico.ca> schreef in bericht news:Xn**********************@66.150.105.47...
"Arno R" <ar***********@tiscali.nl> wrote in
news:44**********************@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
Jun 14 '06 #6
"AA Arens" <ba***********@gmail.com> wrote in message
news:11*********************@f6g2000cwb.googlegrou ps.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?
Jun 15 '06 #7
Comile Error: Method or data member not found

Bart

Keith Wilby wrote:
"AA Arens" <ba***********@gmail.com> wrote in message
news:11*********************@f6g2000cwb.googlegrou ps.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?


Jun 16 '06 #8
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

Arno R wrote:
"Bob Quintal" <rq******@sPAmpatico.ca> schreef in bericht news:Xn**********************@66.150.105.47...
"Arno R" <ar***********@tiscali.nl> wrote in
news:44**********************@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


Jun 16 '06 #9
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.
Jun 16 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Adrian Parker | last post by:
Hello all. I have a Access database which I read records from. All the records read fine, except the Date/Time field of the database is not being properly assigned to my Date-Time-Picker control...
5
by: akoper | last post by:
I have a table that is a project. Each record is a task in the project. One field in each record is a date/time stamp for when that task was completed. I need to be able to: 1) compute how much...
2
by: JP SIngh | last post by:
Can someone please suggest the correct way to store the date & time in SQL Server? I want to store the date and time a record was created. What should the field type be in SQL Server? How can...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
1
by: Robert | last post by:
Does the ! work with Date/Time fields. I have a fields that is set as a Date/Time fields - Short Time and I want it to fill in from right to left as Access claims it will. I tried the example that...
2
by: john | last post by:
From an Excel-import I have an access table with a datetime field of wich both date and time are entered. I've set the field's notation properties to Short Date. When I view the table in tableview...
0
by: RSH | last post by:
Hi, I have a situation where I am using a dataset from a SQL Query. SQL's DateTime is a "long date/time field" which includes the Date/Time. My fields need to be displayed in a short time...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
4
by: purnimakhamri | last post by:
hi can any body tell the code for date time picker using calendar control .Am using ASP.NET 2.0 ..calandar control must be in hidden field ,if i click on that it will pop up and display the date and...
9
by: JeremyI | last post by:
I am writing code to import assessment information about a building from an Excel file (populated by a mobile interviewer on a laptop) into an Access database. With much trial and error, I've hit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.