Date Stamp

yhchen

Registered User.
Local time
Today, 02:34
Joined
Jul 6, 2008
Messages
63
Hello....

Hope someone here knows about the answer about this:

When user attempted to update a record in the form, I would like the field "lastupdate" to be datestamped if the field Confirm Update (yes/no) is ticked...

I tried to use IIf([Update],Date(),"") but it's not working...

Hopefully someone here knows how to resolve this problem...

Many thanks in advance for any help you can offer.
 
Hello....

Hope someone here knows about the answer about this:

When user attempted to update a record in the form, I would like the field "lastupdate" to be datestamped if the field Confirm Update (yes/no) is ticked...

I tried to use IIf([Update],Date(),"") but it's not working...

Hopefully someone here knows how to resolve this problem...

Many thanks in advance for any help you can offer.

I will assume that the field "CONFIRM" is a Boolean field and that it is linked to (hypothetical) "CHECK50". On the after update event for CHECK50 you can have the following.

Code:
oldlastupdate = lastupdate
IIF(Check50,date(),oldlastupdate)
 
Thank you Steve, but it doesn't work...

Attached the design view screenshot:

samples.jpg


I put down:

Code:
Private Sub Update_After()
oldlastupdate = LastUpdate
IIF(Update,date(),oldlastupdate)
End Sub
Nothing happened.....

only that in the code view, the line of IIF appears as red...

any idea??

another question though... I don't have a field called oldlastupdate....??
 
I may have been too cryptic. I should have included "lastupdate=". Sorry about that.
Code:
oldlastupdate = lastupdate
lastupdate = IIF(update,date(),oldlastupdate)

I don't know what others would suggest, but as I have gained more experience with Access, it seems to me that you should not use the same name for a control as its underlying field. So if you have a field "update", the linked control would be something like "update1".
 
Last edited:
I may have been too cryptic. I should have included "lastupdate=". Sorry about that.
Code:
oldlastupdate = lastupdate
lastupdate = IIF(update,date(),oldlastupdate)
I don't know what others would suggest, but as I have gained more experience with Access, it seems to me that you should not use the same name for a control as its underlying field. So if you have a field "update", the linked control would be something like "update1".

Thanks Steve....it's still not working though... :(

no debug message nor error message, just nothing happened....

You mentioned earlier that the [Update] should be a Boolean field and that it is linked to [lastupdate] and I am not quite sure about what you meant about that...

as you can see from the table structure, they are both in one table... could this be the problem? If so, how should I *link* these two fields?

ps. I have changed the name of the control...
 
By Boolean this means that the check box is either "true" or "false". If it is checked the value is normally "true" which means that the IIF statement returns "date()" when checked.

It looks like your syntax is wrong for the subroutine, it should be:
Code:
Private Sub Update_AfterUpdate()
oldlastupdate = lastupdate
lastupdate = IIF(update,date(),oldlastupdate)
End Sub

Take a look at the property sheet for "update". Under events you should see "after update" on the left column and to the immediate right you should see "[Event Procedure]", that tells access to run the code in the subroutine. If "[Event Procedure]" is not that there you will need to add it. (Don't use the "") Again, I would caution to not use "reserved" words such as "Update" for a control name. You may want to change it to something like "Update1", so that it is clearly distinguishable.
 

Users who are viewing this thread

Back
Top Bottom