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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Date Modified 2

Status
Not open for further replies.

Elvis72

Technical User
Dec 6, 2007
211
US
OK, I have searched and searched, while I have found helpful posts I can't find one that hits home with what my end goal is.

I have a Main Form, then I have multiple SubForms, I need to have a field on the Main Form that shows the date something on the Main Form or Subforms was last updated.

I can't seem to find something that would recognize when the subforms were changed?

Whatever information you need please let me know!~

Thanks so much!~

 
I am a little confused as to what you want. Do you want to know when the form has changed, as in the design of the form? Or do you want to want to know when data has changed as in a field in a table?

The part of you post that confused me is:
Elvis72 said:
I need to have a field on the Main Form
because, tables have fields, forms have controls.

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
OK, sorry for the confusion...

I need to have the date last modified show up on the main form when a record is edited.

Thanks!~
 
I do not know if there is a way to tell when a record is edited. (But my knowledge is pretty limited)

However, couldn't you make a date field in your tables and have your forms write the current date/time in that field whenever they update a record? Then you could access that field like any other.

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Hi there,

I use the AFTER UPDATE event to all important fields that got updated and which when updates will subsequently update the STSdate ( short for Status changed date).

This is how i did it.

Lets say I have two fields in a table called PAt and there is a Main form called FORM PAT and a sub form called Form SUb_pat - where users update event dates on a regular basis. For my example i will just use 2 of the fields frequently used:

Regstdate
Exitdate

To capture changes made to these 2 flds I have also created a field called STSDATE in that PAT table.

In the Sub form attached to the main form ( you add the stsdate and using the properties HIDE it so it gets updated in the background

everytime the user updates either the REGStTDATE or EXITDATE,

my AFTER UPDATE Event for each of the above flds will have this

me!stsdate = me!regstdate

that way at end of mth i can pick out all clients with status changes. I have over 20 fields that monitor the dates changed and i have attached the code to each of these fields for the After Update EVENT. I have more code that goes in for that event , but to answer your question, the above code shd suffice I think

Hope this helps

Usha


me!stsdate =
 
Well, What I need is a bit more complicated, I need to know if ANY field in the subforms or main form have been updated and capture that date?

 
You can use the After Update event of each of the subforms to write to the main control, which can be hidden, that is bound to the update field.

Me.Parent.txtLastUpdate=Now()
 
I need to know if ANY field...have been updated and capture that date?

Then, wouldn't you need a last date modified field for each field that you are tracking? Now, I wouldn't be sure of the best way to code this (I would hack through it personally) but, you could just have a date field for each of your other fields (i.e. if you have one called lastName you could have one called lastNameModified to track that field and so on for each field).

Then, on the before update even on your form, check to see if the field is going to change, and if it is write the current date/time in the appropriate field.

One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
 
Remou -

I just tried the:

Me.Parent.txtLastUpdate=Now()

I am getting an error message that says:

Microsoft Office Access can't find the macro 'me'

Which I'm not understanding?

 
When you say subforms do you mean a subform on a main form in a subform control? When you say the After Update event, do you mean written on the After Update line or in the code module belonging to the form? I mean the code module belonging to the form, you can use the line, but you would need to create a funtion.
 
OK, I have the txtbox on the main form and then on the subforms in the event: After Update I have:

Me.Parent.txtLastUpdate=Now()

 
It should read:

[tt]After Update........ [Event Procedure][/tt]

Then there should be code:

Code:
Private Sub Form_AfterUpdate()
    Me.Parent.txtLastUpdate = Now()
End Sub
 
This works wonderfully...except for one thing...

When I try and go to a different tab on the form it is giving me the Microsoft Office Access can't find the macro '.'

???
 
Have you left anything on one of the lines?

After Update........ [Event Procedure]

The dots in the line above should not be typed in, they are there already, do not type anything on to the lines unless you are sure of what you are doing. Just select from the dropdown list.
 
All I did was paste your:

Me.Parent.txtLastUpdate = Now()

Between the existing:

Private Sub Form_AfterUpdate()

End Sub

I've checked every code on all the subforms....same thing?

After I click on one of the tabs that message comes up, but then it opens the tab, and the date is updated?

Sooo, confused
 
OK, when I added the code in just the After Update Evet Line it gave me the same error but it was the 'Me' macro.

Before I started any of that it had no errors or issues.
 
Look at the property sheet for the form. All the events should be either blank or [Event Procedure].
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top