Two Questions

jmriddic

Registered User.
Local time
Today, 22:28
Joined
Sep 18, 2001
Messages
150
Is there a way to enable/disable or lock/unlock all the fields on a form for a record so if one person puts in a record, clicks the button and locks the fields and leaves the database and someone else comes in and brings the record up they can look at the record but cannot make changes to it unless the button is clicked again to unlock it. Also is there any way to display the last date the record was edited. Thanks.
 
Make an extra field in the table called lockedID

And if its on, disable all the fields on form update, if its off, enable them.

For the last date, have a date field, and when the form update (i think its form update), have it put the current date and time into that field.
 
Followup

What kind of field would this be ? Yes/No? Do you know how I would access Form update?
 
Does this gray out all the fields

Does this gray out all the fields?
 
I guess the code goes in the click event of the button?
 
Reason

I do want to lock the record but how would the user know the record locked. I thought grayed out boxes would be the result. But I did try it. One little problem I cannot uncheck that box to edit that record now. Hmm..

As far as my other post:

I put this in the Form After Update event:

Me.Edited =Date()

Ok I make any edit and close that form which takes me to my lookup form. I don't have a save button but anyway..
I go back into the record and that field is still blank. What am I not doing?
 
Response

My close button does this:

On Error GoTo Err_cmdClose_Click


DoCmd.Close
DoCmd.OpenForm "frmSearch", acNormal

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
 
Trying something

Pat,

I was going to try to put it in a button so it would unlock and locked based on the button like so and the field would manly be used for displayed :

If Me.LockedId Then
Me.LockedId = 0
Me.AllowEdits = True
Else
DoCmd.RunCommand acCmdSaveRecord
Me.LockedId = -1
Me.AllowEdits = False

It will let me let me unlock but not locked. any suggestions?
 
Yes but

Ok,

I am getting a VB error 2046 and something that you can't save now. Move it to before the IF and it got the rror when unlocking. Removed it and it doesn't lock but changes the value of the button. Go out and come back in and its lock but unlock it and try to lock it again it will not do it.
 
Code

Hi Pat,

I tried this and it seemed to work and I also took the code out of the other events and it seem to work so I think I got it.

If Me.LockedId Then
Me.LockedId = 0
Me.AllowEdits = True

Else
Me.LockedId = -1
DoCmd.RunCommand acCmdSaveRecord
Me.AllowEdits = False
End If
 

Users who are viewing this thread

Back
Top Bottom