last updated & last viewed

peterjb44

Registered User.
Local time
Today, 01:00
Joined
Mar 7, 2013
Messages
55
Hi all,

how can I get dates to show in last updated and last viewed fields

I've tried to do it, I did get last updated working but for some reason when I tried to do last viewed, last updated vanished :/

I did try writing code (but im a novice lol, I think that's why last updated vanished)

I have got 2 unbound fields called HiddenLastViewed and HiddenLastUpdated thought I might need them

whats the best way to do it...

thanks

peter
 
For last viewed could you not simply use the following in the form's On Current event;
Code:
Me.LastViewed = Now()

and for last Modified the following code in the form's On Dirty event;
Code:
Me.LastUpdated = Now()
 
Hi alan and john, thanks for your replies......

john I tried what you put and last viewed works fine but last updated does not show up

I even tried after update and on data change in form events and still no date showing in last updated

any ideas!!

thanks

peter
 
Strange; I've just had a play in my sand box DB, with
Code:
Me.LastUpdated = Now()
in the form's On Dirty event, the LastUpdated field gets gets updated as soon as you make a change to any field on the form.
 
Hi John,

ok, I've found out how I can get last updated to work, but it only works for one field at a time, if I have to change two field then I would have to repeat

when the form opens on the left hand side is a bar with a pencil in it at the top, if I click that bar it turns black and a arrow pointing right appears in white to replace the pencil, then when I type in a field the last updated works :confused:

any ideas how I can sort this?

let me know if you need more info

thanks

peter
 
Peter, the bar (called the Record Selector) denotes if a record is dirtied or not.. Based on your description..
when the form opens on the left hand side is a bar with a pencil in it at the top,
It shows that the Form is dirtied on Open, that might be because of the Form Current method.. The pencil appears only when the data in the form is changed..
if I click that bar it turns black and a arrow pointing right appears in white to replace the pencil,
Clicking on the record selector will make an implicit save.. Thus explaining why the value changes
when I type in a field the last updated works :confused:
Technically the Form current and Form dirty happens at the exact same time (ofcourse with some micro second difference)

So move the LastUpdated bit into the Before Update event of the Form..
 
Hi pr2-eugin,

thanks for the reply,

that works, thanks for explaining, I'm new to this and that helps :)

peter
 
well, it is working, but it also works if I change nothing :confused:

peter
 
OK, been having a bit more of a mess around in the sand box, and the following should do what you want;

for the last viewed put the following code in the form's On Current event;
Code:
Me.LastViewed = Now()
Me.Dirty = False
and last updated use the following in the Form's On Dirty Event;
Code:
Me.LastUpdated = Now()
Thanks pr2-eugin for nudging me in the right direction :)
 
Hi John,

thanks for the reply,

lol, it works, but now when I click on CustomerID to open up the record I what to edit it now only opens CustomerID record 1

let me know if you need more info


peter
 
Thanks pr2-eugin for nudging me in the right direction :)
He he.. Did I ?? :D

I did tell Peter(OP) that Form_Current makes the Form dirty, but I did not; for a second think it will inturn call Form_BeforeUpdate, apparently at a later stage.. Lol.. So :o
 
Are you able to post a copy of your DB?

First do a compact and repair on it then put it in a zip and follow the direction here.
 
He he.. Did I ?? :D

I did tell Peter(OP) that Form_Current makes the Form dirty, but I did not; for a second think it will inturn call Form_BeforeUpdate, apparently at a later stage.. Lol.. So :o

The On Current event code I was suggesting was making the form dirty, but it does not trigger the Form's On Dirty event. So when I tested my On Dirty code, which I was doing, in isolation it worked not problems. However when combined with my On Current code it wasn't firing, but adding Me.Dirty = False to the On Current event fixed that :)
 
form CustomerRDS is where I set up the on click event for CustomerID to open up form CustomerR

mainR is the main form I want to use which is a navigation form

what I need is when in mainR if I click on any CustomerID I brings up that record to view/edit

peter
 
I found out why only record 1 was showing.

I must of deleted the where condition in openform

it should have been [CustomerID]=[Forms]![MainR]![CustomerRDS]![CustomerID]

thanks for helping


peter
 

Users who are viewing this thread

Back
Top Bottom