Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Date Entry 1

Status
Not open for further replies.

alvinmcg

Technical User
Oct 21, 2003
24
US
I need to automatically add the current date to a record if the record is updated. I have seen some terrific wizardry in this forum but nothing I have tried has worked.

Specifically, I have added a date field "updated" to my table. If the record is changed in any way, I want the current date stored in the "updated" field.

The table has several linked tables. I want this to work if a child table is edited as well.

I am working in PDOX 8.

Thank you for your help.
 
There are many ways you could do this, a simple way would be to use recordStatus() to see if the record is modified, you can attach the code on the depart event for the record of the master and any detail tables.

if recordstatus("Modified") then
dmPut("TableName","updated",today())
endif

Hope this helps.
Perrin
 
Thank you for your suggestion. Can you explain "the depart event for the record of the master and any detail tables"? I do not see a "depart" event when looking in "Object Explorer."

I added your code to the "canDepart" event on the Notebook. I did substitute the name of the table in the code for "TableName". However, it does not appear to work.

This must sound really simple to many on this list but I hope you can help.
 
If you don't see the "depart" event then you probably have your preferences set for "Beginner", to change this go to Tools -> Settings -> Developer Preferences and make sure "ObjectPal Level" is set to "Advanced". Once you do this you will find you have a lot more built in events to work with.

Perrin
 
OK, I have confirmed my settings were set to beginner and changed it to advanced.

However, and I know this is basic, how do I attach the code to the
"depart event for the record of the master and any detail tables."

Do I attach the code to the Form, Page, Notebook, Notepage or one of the many fields within the form?

Thank you for your patience as you are helping me through this.
 
I have added the code to each page of my multipage form hoping that any change which may be made on that page would automatically force the update.

This works great but only on the page which includes information to the master record. Updating any of the child tables does not cause an update to the date as desired.

What am I missing (besides years of experience).
 
It sounds like it should be working, can you post the code you are using?
 
if recordstatus("Modified") then
dmPut("projects","updated",today())
endif

This code has been added to the depart event for each of the eight pages to this form.

I just tested the form again by adding information to several of these child tables and none of them resulted in updating the Updated field in the parent table.
 
I have a feeling that the recordStatus is not being triggered where you have the code, the code needs to be on the record not the page. You can easily add a msgbox to see if recordstatus is being triggered.

if recordstatus("Modified") then
msginfo("Works","Modified Record")
dmPut("projects","updated",today())
endif

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top