Lock an object after update

Lloyd

Registered User.
Local time
Today, 03:56
Joined
Sep 6, 2005
Messages
16
Hi

I have setup bound objects on a form which I will be linking files from server. After I have inserted the files I want them to be locked so nobody can change them. I have tried various bits of code in "after update" but I keep getting errors. Can anybody help?

Thanks
 
ok -

in access i would do the follwoing
in my underlying table have a lockfield yes/no
set to no
and records that require to be locked set it to yes and on your form add this properties visible no
and on your form properties have is me.lockfield=yese then fieldnames.locked
or somthing along those lines


I have this in one of my forms
select from a drop down populates a given field upon saving /exiting it locks this field and is unchangeable (ish) if people get in the back end then its changable)

works for me I have all sorts of variations on this i have a declined tick box if selected greys out the data, another one cover effected which disables the declned option (You cannot be effected and declined)

might not be what you are after but might give some pointers
g
 
Cheers, I just wanted a small bit of code though. I tried the following:

Private Sub attach1_AfterUpdate()

DoCmd.RunCommand acCmdSaveRecord
Me.attach1.Locked = True

End Sub

I got an error message "The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing database from the saving the data in the field".

Now I dont have any rules or before event macros so i dont know why this is happening?
 
I do'nt think there is any reason to save the record in the after update event, if anything you should save after setting the yes/no field to yes or no.

Access uses -1 for true and 0 for false try that instead of true or false
 
You could try

me.Allowedits = True (to allow edits)

and

me.Allowedits = false (to lock the record)
 

Users who are viewing this thread

Back
Top Bottom