473,800 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Time Stamp entries?

I need to associate a Creation Date and a Modified Date with each entry in
my database. How to do this?

Here's what I've tried:

1) Use a separate table (tblUpdate) with Created, Modified, and Entry_ID
fields that has a One-To-Many relationship with the main table (tblMain -
the "one" side of the relationship) which holds all the names, addresses,
etc.

2) Have an update query run every time an entry is added, or modified:

UPDATE tblUpdate SET tblUpdate.Modif ied = Now()
WHERE (("Entry_ID"=[Forms]![frmMain]![frmCn].[Form]![Entry_ID]));

But how do I get every Entry_ID from tblMain into tblUpdate? Do I have to
write it every time? What if the Entry_ID does not yet exist? Does that
mean I also need an Append Query for new entries in tblMain?

If possible, I want to avoid having any form associated with tblUpdate
because I'll be writing to it from several different forms and subforms
within the database. Does this mean I'll be updating it exclusively with
SQL statements rather than Jet? Is there a performance penalty for doing
this?

Has anyone done this before? Is there a better way?

Thanks in advance!!
Nov 12 '05 #1
7 15541
I don't believe you have any choices here.
You have to run the code in every place where you allow updates to take
place.
But I can see no point at all in making it so difficult by putting the
fields into a separate table.

If the fields were in the same table as the data then
the creation date could be entered automatically with a default value of
Now. You would just need a me.lastmodified = Now statement in the form's
beforeupdate event wherever you allow changes.

Regards

Peter Russell

deko previously wrote:
I need to associate a Creation Date and a Modified Date with each entry
in
my database. How to do this?

Here's what I've tried:

1) Use a separate table (tblUpdate) with Created, Modified, and
Entry_ID
fields that has a One-To-Many relationship with the main table (tblMain
-
the "one" side of the relationship) which holds all the names,
addresses,
etc.

2) Have an update query run every time an entry is added, or modified:

UPDATE tblUpdate SET tblUpdate.Modif ied = Now()
WHERE (("Entry_ID"=[Forms]![frmMain]![frmCn].[Form]![Entry_ID]));

But how do I get every Entry_ID from tblMain into tblUpdate? Do I have
to
write it every time? What if the Entry_ID does not yet exist? Does
that
mean I also need an Append Query for new entries in tblMain?

If possible, I want to avoid having any form associated with tblUpdate
because I'll be writing to it from several different forms and subforms
within the database. Does this mean I'll be updating it exclusively
with
SQL statements rather than Jet? Is there a performance penalty for
doing
this?

Has anyone done this before? Is there a better way?

Thanks in advance!!


Nov 12 '05 #2
hmmm... sounds like a plan... BUT:

1) sometimes I'm in a subform, or popup form, or other form that holds data
associated with the entry in question. This other form does NOT use tblMain
as a RecordSource. So, when a change is made, the Modification Date needs
to be written... the only way I know how to do this is:

DoCmd.RunSql ("UPDATE tblMain SET ModificationDat e = Now() WHERE
Entry_ID = " & Me!Entry_ID)

After I do this, there are conflicts when I go back to frmMain (The form
that DOES use tblMain as a RecordSource) and try to make additions/edits
AFTER writing the Modification Date to the underlying table.

Do I need to requery the main form every time the ModificationDat e is
changed? If so, This means I have to also move frmMain back to the record
it was on before the write (or else the user has to manually go back).
Here's how I do it in code:

Dim rst as DAO.recordset
Set rst = Me.RecordsetClo ne
rst.FindFirst ("Entry_ID=" & lngEid)
Me.Bookmark = rst.Bookmark
rst.Close
Set rst = Nothing

(does this code look okay, by the way?)

2) ALSO -- if frmMain is Dirty, then does it have to be requeried BEFORE the
Modification Date is written? I've gotten errors when this is the case...

3) ALSO -- what about the size of tblMain? Will all these dates cause it to
grow too fast? Wouldn't it be better to have all the dates in a separate
table -- AND would this avoid the conflicts and requery/move-back issues
mentioned above??

Thanks again for the reply and advice!
"Peter Russell" <ru***@127.0.0. 1> wrote in message
news:me******** *************** @russellscott.b tinternet.com.. .
I don't believe you have any choices here.
You have to run the code in every place where you allow updates to take
place.
But I can see no point at all in making it so difficult by putting the
fields into a separate table.

If the fields were in the same table as the data then
the creation date could be entered automatically with a default value of
Now. You would just need a me.lastmodified = Now statement in the form's
beforeupdate event wherever you allow changes.

Regards

Peter Russell

deko previously wrote:
I need to associate a Creation Date and a Modified Date with each entry
in
my database. How to do this?

Here's what I've tried:

1) Use a separate table (tblUpdate) with Created, Modified, and
Entry_ID
fields that has a One-To-Many relationship with the main table (tblMain
-
the "one" side of the relationship) which holds all the names,
addresses,
etc.

2) Have an update query run every time an entry is added, or modified:

UPDATE tblUpdate SET tblUpdate.Modif ied = Now()
WHERE (("Entry_ID"=[Forms]![frmMain]![frmCn].[Form]![Entry_ID]));

But how do I get every Entry_ID from tblMain into tblUpdate? Do I have
to
write it every time? What if the Entry_ID does not yet exist? Does
that
mean I also need an Append Query for new entries in tblMain?

If possible, I want to avoid having any form associated with tblUpdate
because I'll be writing to it from several different forms and subforms
within the database. Does this mean I'll be updating it exclusively
with
SQL statements rather than Jet? Is there a performance penalty for
doing
this?

Has anyone done this before? Is there a better way?

Thanks in advance!!

Nov 12 '05 #3
"deko" <dj****@hotmail .com> wrote in message news:<DA******* **********@news svr27.news.prod igy.com>...
I need to associate a Creation Date and a Modified Date with each entry in
my database. How to do this?


RTFM.
Creation Date: Default Value (table level) = Date() or Now()
Modified Date: Set in the BeforeUpdate event of a form... can't be
done at table level.
Nov 12 '05 #4
deko previously wrote:
hmmm... sounds like a plan... BUT:

1) sometimes I'm in a subform, or popup form, or other form that holds
data
associated with the entry in question. This other form does NOT use
tblMain
as a RecordSource. So, when a change is made, the Modification Date
needs
to be written... the only way I know how to do this is:

DoCmd.RunSql ("UPDATE tblMain SET ModificationDat e = Now() WHERE
Entry_ID = " & Me!Entry_ID)


You've lost me.

How can you be changing (through the UI) a field in tblMain if the form is
not based on that table? And if you're not changing a record in tblMain
why would you want to update its modification date?

Regards

Peter Russell

Nov 12 '05 #5
good question.

I have a table (tblTxJournal) which holds transactions for each Entry. Each
Entry's Entry_ID is in tblTxJournal (I think this is called a Foreign Key?)
with a One-To-Many relationship with tblMain (tblMain is the "one" side).
The UI is a tabbed interface, so when the user goes to enter/add a
transaction on frmTx, frmMain remains open, and the Entry_ID is pulled from
frmMain when editing/saving a transaction:

Private Sub cmdRecord_Click ()
lngEid = Forms!frmMain!E ntry_ID 'get Entry_ID
Me!Entry_ID = lngEid 'put it in txtBox bound to Entry_ID in tblTx
DoCmd.RunComman d acCmdSaveRecord
End Sub

Whenever an Entry's transaction is modified/added, the DateModified field
(in tblMain) needs to be updated. One way to do this would be adding this
line to the above sub on frmTx:

Forms!frmMain!D ateModified = Now

This would set the current date on frmMain (and the underlying RecordSource
tblMain) -- without the user actually being in that form.

But problems arise when the user goes back to frmMain and makes changes --
or goes to frmTx while frmMain is Dirty. This is why I'm thinking a
separate table might be best -- simply to avoid problems.

UPDATE tblUtility SET Modified = Now()
WHERE Entry_ID=Forms! Tx!Entity_ID;

What do you think?
"Peter Russell" <ru***@127.0.0. 1> wrote in message
news:me******** *************** @russellscott.b tinternet.com.. .
deko previously wrote:
hmmm... sounds like a plan... BUT:

1) sometimes I'm in a subform, or popup form, or other form that holds
data
associated with the entry in question. This other form does NOT use
tblMain
as a RecordSource. So, when a change is made, the Modification Date
needs
to be written... the only way I know how to do this is:

DoCmd.RunSql ("UPDATE tblMain SET ModificationDat e = Now() WHERE
Entry_ID = " & Me!Entry_ID)


You've lost me.

How can you be changing (through the UI) a field in tblMain if the form is
not based on that table? And if you're not changing a record in tblMain
why would you want to update its modification date?

Regards

Peter Russell

Nov 12 '05 #6
I don't know if I'm getting somewhere near it yet.

My understanding now is that you have a main table and a transactions
table.

The transaction are all timestamped.

What you want is the form for the main table to display the latest
timestamp on any related transaction.

If this is the case then don't keep the timestamp data on the main table
at all. Just look it up using DMax. You can requery the field after each
transaction.

Am I missing the point here?

Regards

Peter Russell


deko previously wrote:
good question.

I have a table (tblTxJournal) which holds transactions for each Entry.
Each
Entry's Entry_ID is in tblTxJournal (I think this is called a Foreign
Key?)
with a One-To-Many relationship with tblMain (tblMain is the "one"
side).
The UI is a tabbed interface, so when the user goes to enter/add a
transaction on frmTx, frmMain remains open, and the Entry_ID is pulled
from
frmMain when editing/saving a transaction:

Private Sub cmdRecord_Click ()
lngEid = Forms!frmMain!E ntry_ID 'get Entry_ID
Me!Entry_ID = lngEid 'put it in txtBox bound to Entry_ID in tblTx
DoCmd.RunComman d acCmdSaveRecord
End Sub

Whenever an Entry's transaction is modified/added, the DateModified
field
(in tblMain) needs to be updated. One way to do this would be adding
this
line to the above sub on frmTx:

Forms!frmMain!D ateModified = Now

This would set the current date on frmMain (and the underlying
RecordSource
tblMain) -- without the user actually being in that form.

But problems arise when the user goes back to frmMain and makes changes
-- or goes to frmTx while frmMain is Dirty. This is why I'm thinking a
separate table might be best -- simply to avoid problems.

UPDATE tblUtility SET Modified = Now()
WHERE Entry_ID=Forms! Tx!Entity_ID;

What do you think?
"Peter Russell" <ru***@127.0.0. 1> wrote in message
news:me******** *************** @russellscott.b tinternet.com.. .
deko previously wrote:
hmmm... sounds like a plan... BUT:

1) sometimes I'm in a subform, or popup form, or other form that
holds
data
associated with the entry in question. This other form does NOT use
tblMain
as a RecordSource. So, when a change is made, the Modification Date
needs
to be written... the only way I know how to do this is:

DoCmd.RunSql ("UPDATE tblMain SET ModificationDat e = Now() WHERE
Entry_ID = " & Me!Entry_ID)


You've lost me.

How can you be changing (through the UI) a field in tblMain if the
form is
not based on that table? And if you're not changing a record in
tblMain
why would you want to update its modification date?

Regards

Peter Russell



Nov 12 '05 #7
well, I've prototyping the separate table solution and it seems to be
working.

what I have is an append query that inserts creation date in tblUtility for
new entries, and an Update query that writes modification dates to that same
table. The key was to know where to fire off the Update query -- your
suggestion of on BeforeUpdate is a winner.

I have many tables that are all linked on Entry_ID with many forms that use
these tables as recordsources. The solution I've designed will allow me to
update the modification date for a particular Entry when related data for
that Entry -- in any of the related tables -- is changed. And because
tblUtility is not used as a recordsource for any form, I don't have to worry
about write conflicts and other problems that I've experienced when I tried
to use tblMain for this.

thanks for the time on DMax... may come in handy elsewhere

appreciate your comments very much!!
"Peter Russell" <ru***@127.0.0. 1> wrote in message
news:me******** *************** @russellscott.b tinternet.com.. .
I don't know if I'm getting somewhere near it yet.

My understanding now is that you have a main table and a transactions
table.

The transaction are all timestamped.

What you want is the form for the main table to display the latest
timestamp on any related transaction.

If this is the case then don't keep the timestamp data on the main table
at all. Just look it up using DMax. You can requery the field after each
transaction.

Am I missing the point here?

Regards

Peter Russell


deko previously wrote:
good question.

I have a table (tblTxJournal) which holds transactions for each Entry.
Each
Entry's Entry_ID is in tblTxJournal (I think this is called a Foreign
Key?)
with a One-To-Many relationship with tblMain (tblMain is the "one"
side).
The UI is a tabbed interface, so when the user goes to enter/add a
transaction on frmTx, frmMain remains open, and the Entry_ID is pulled
from
frmMain when editing/saving a transaction:

Private Sub cmdRecord_Click ()
lngEid = Forms!frmMain!E ntry_ID 'get Entry_ID
Me!Entry_ID = lngEid 'put it in txtBox bound to Entry_ID in tblTx
DoCmd.RunComman d acCmdSaveRecord
End Sub

Whenever an Entry's transaction is modified/added, the DateModified
field
(in tblMain) needs to be updated. One way to do this would be adding
this
line to the above sub on frmTx:

Forms!frmMain!D ateModified = Now

This would set the current date on frmMain (and the underlying
RecordSource
tblMain) -- without the user actually being in that form.

But problems arise when the user goes back to frmMain and makes changes
-- or goes to frmTx while frmMain is Dirty. This is why I'm thinking a
separate table might be best -- simply to avoid problems.

UPDATE tblUtility SET Modified = Now()
WHERE Entry_ID=Forms! Tx!Entity_ID;

What do you think?
"Peter Russell" <ru***@127.0.0. 1> wrote in message
news:me******** *************** @russellscott.b tinternet.com.. .
deko previously wrote:

> hmmm... sounds like a plan... BUT:
>
> 1) sometimes I'm in a subform, or popup form, or other form that
> holds
> data
> associated with the entry in question. This other form does NOT use
> tblMain
> as a RecordSource. So, when a change is made, the Modification Date
> needs
> to be written... the only way I know how to do this is:
>
> DoCmd.RunSql ("UPDATE tblMain SET ModificationDat e = Now() WHERE
> Entry_ID = " & Me!Entry_ID)

You've lost me.

How can you be changing (through the UI) a field in tblMain if the
form is
not based on that table? And if you're not changing a record in
tblMain
why would you want to update its modification date?

Regards

Peter Russell


Nov 12 '05 #8

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

Similar topics

2
6093
by: Marcus | last post by:
I am having some problems with trying to perform calculations on time fields. Say I have a start time and an end time, 1:00:00 and 2:30:00 (on a 24 hour scale, not 12). I want to find the difference in minutes, divide this result by a predefined size of interval, and make a loop that runs this many times. For example, with an interval size of 15 minutes, it will return 6 blocks... I have this all working fine, but am getting stuck on...
10
4760
by: Yang Li Ke | last post by:
Hi guys, Im about to build a script which will log visitor time spent on my website. I got a few ideas about this, maybe checking visitors ip and storing that info in db with time in and then using session vars to check time out ... Anyone has any ideas about doing that kind of script? Thank you! -- Yang
1
5369
by: Bill | last post by:
I have a shopping cart that will get full from time to time because customers click out of the site before they confirm their purchase, therefore leaving a full cart behind. I'd like to have a timestamp on this table, so that I can delete anything that I find is more than a day old. How can I do this? Thanks,
7
19634
by: Don | last post by:
Hi all, With regards to the following, how do I append the datetimestamp to the filenames in the form? The files are processed using the PHP script that follows below. Thanks in advance, Don Following running on client-side:
18
3926
by: Sven | last post by:
Hi, I found a strange behaviour when using the time() function from time.h. Sometimes when it is called, it does not show the correct time in seconds, but an initial value. This time seem to be the time when the program was started the first time. My platform is a DEC machine with Tru64 onboard. A possible explanation could be, that the time() function is called
3
17614
by: phried1 | last post by:
I have created a form and inserted the following tables: Date Entered Time Entered Date Modified Time Modified Essentially how and where can I have these dates and times recorded so when the user creates a new record that date and time stamp is populating as well as if the user modifies the data, that date and time stamp is populationg. Whereby if the record was created yesterday, and the user modified the record today, i would see...
1
1689
MitchR
by: MitchR | last post by:
I have created a text box and scripted it to receive a line of text and current date upon completion of a scripted event. My question is this. I need to script this text box and date stamp to receive multiple entries. The Date stamp is captured by a field in my primary table and saved. I need to be able to script multiple date stamp. Here is my code for the date Stamp: !! = "Date of Execution " & myDate & "; "
4
6810
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 allows the employee to enter their UserID and select "Login" or "Logout" and then click a submit. When the submit button is clicked, I want the application to dum the NT Userename, UserID, status (Login or Logout) and a date/time stamp into an MS Access...
2
1864
by: Shane | last post by:
I'm writing a program for renaming my picture files, and I want to use the picture time stamp as a prefix to the file names. I can get the time stamp, but it is extraordinarily slow! I have about 250 pictures in the directory. In debug mode, I can populate the names in a listview in less than two seconds. If I add a column with the time stamp as a string, the listview takes about 70 seconds to populate in debug mode. I haven't made and...
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10276
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10035
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.