Lock record from editing after 1 day?

  • Thread starter Thread starter gdai
  • Start date Start date
G

gdai

I'm looking for a way to set up a table so that all the records which are
older than one day cannot be edited - only copied and edited. There is a
date field in the records to work with. Anyone have any ideas on how to
accomplish this?
Thanks...
Gary
 
gdai said:
I'm looking for a way to set up a table so that all the records which are
older than one day cannot be edited - only copied and edited. There is a
date field in the records to work with. Anyone have any ideas on how to
accomplish this?
Thanks...
Gary
Yes!

My timestamp field in the example is called 'changed'. Use a table
validation rule (huh? Design table, choose Properties) and set the rule to
[changed]>(Now()-DateSerial(0,0,1))
i.e. the record is valid only if the date is after yesterday.

I also put something in the validation message, like 'this record has
been closed'.
 
I had experimented a bit with something similar to this and it worked fine
except that the record couldn't be copied then edited. Essentially what I'm
doing is creating a new record from a copy of an old one and editing some
fields in the new record. Since the validation rule locks the new record for
editing once it's copied, it won't work. Thanks for your input though.
Gary


Bas Cost Budde said:
gdai said:
I'm looking for a way to set up a table so that all the records which are
older than one day cannot be edited - only copied and edited. There is a
date field in the records to work with. Anyone have any ideas on how to
accomplish this?
Thanks...
Gary
Yes!

My timestamp field in the example is called 'changed'. Use a table
validation rule (huh? Design table, choose Properties) and set the rule to
[changed]>(Now()-DateSerial(0,0,1))
i.e. the record is valid only if the date is after yesterday.

I also put something in the validation message, like 'this record has
been closed'.
 
gdai said:
I had experimented a bit with something similar to this and it worked fine
except that the record couldn't be copied then edited. Essentially what I'm
doing is creating a new record from a copy of an old one and editing some
fields in the new record. Since the validation rule locks the new record for
editing once it's copied, it won't work. Thanks for your input though.
Gary

Change the date/time to Now() during copy. Or, create a new record and
fill in just the values you need.
 
Thanks for the response. I've been trying to get the date to change to Now()
during copy, but just can't figure it out. I hate to ask for even more help,
but can you elaborate on how you might go about this?
Thanks...
Gary
 
gdavi said:
Thanks for the response. I've been trying to get the date to change to Now()
during copy, but just can't figure it out. I hate to ask for even more help,
but can you elaborate on how you might go about this?
Thanks...
Gary

Asking for more help is one thing one can learn...

Actually, I'd like to know how you are copying this record. I can then
jump in with an instruction how to get today there. (Or tomorrow, that
depends on when I can type my answer ;-) )
 
From within one form, I'm having the user click a button to find a record
matching some criteria they choose. After they find this record, they click
another button to copy the record to a new record. They then edit the values
in the new record. Since the date in the new record is more than one day
old, they cannot save the changes they make to the new record.
Gary
 
gdai said:
From within one form, I'm having the user click a button to find a record
matching some criteria they choose. After they find this record, they click
another button to copy the record to a new record. They then edit the values
in the new record. Since the date in the new record is more than one day
old, they cannot save the changes they make to the new record.
Gary

Post the code for the copy button.
Do you copy the whole record? Does your table have a primary key?
 
Yes, the whole record is copied using the "Copy Record" button. The code for
this button follows. The date field I need to change during copy is
"TransDate". And yes, the table does have a primary key defined. It's an
autonumber field.

Hope you can help!
Thanks...
Gary

Private Sub btnCopyTrans_Click()
On Error GoTo Err_btnCopyTrans_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_btnCopyTrans_Click:
Exit Sub

Err_btnCopyTrans_Click:
MsgBox Err.Description
Resume Exit_btnCopyTrans_Click

End Sub
 
gdavi said:
Yes, the whole record is copied using the "Copy Record" button. The code for
this button follows. The date field I need to change during copy is
"TransDate". And yes, the table does have a primary key defined. It's an
autonumber field.

I was afraid it would be that PasteAppend command. Well, let's get on
with it.

In fact you need just one extra line that pushes the timestamp forward;
but first you have to find the new record. Let's try (fumbles a bit with
another computer) ah, the new record has focus. Good. The line is

me!timestampfield = now()
 
Sheer genius...I had tried everything but the most simple solution. Thanks
so much for all your help!
Gary
 
gdavi said:
Sheer genius...I had tried everything but the most simple solution. Thanks
so much for all your help!
Gary

Simple, once you know. ;-) Glad to be of any help.
 
Back
Top