Record Lock

  • Thread starter Thread starter Samantha Rawson via AccessMonster.com
  • Start date Start date
S

Samantha Rawson via AccessMonster.com

I would like to lock the open record if the status is true (yes/no checkbox). At the minute I manage to do it by disabling and locking all the fields, but this causes the fields in other records to be locked as well. Is there a way to do it so it only locks the records with status.value = true?

Additionally, though a bit harder, I would like to make it so that once the status = yes, objects within that order can be used again by another order, as at the minute it is in a primary key field and does not allow duplicates. I need to not allow duplicates normally, but if the status = yes then the ID of the object needs to be returned to the list to be used by other fields.

Any help with either problem would be much appreciated.

Samantha Rawson
 
Samantha,
I'll respond to question1...
An easier method is to use the OnCurrent event of the form...
If [Status] = True Then
Me.AllowEdits = False
ElseIf [Status] = False Then
Me.AllowEdits = True
End if
Also, you'll need to place the same code on the AfterUpdate event of
[Status]
Now, every time you arrive at a record the record will lock/unlock
accordingly, and if you change the Status, the record will lock/unlock
accordingly.

Not sure I understand question 2. If no one responds, try reposting with
more details as to what you're trying to do, and use fieldnames and form
names.

hth
Al Camp
 
Thanks for the help, but I can't get it to work and have no idea why. I get an error message on click of 'Member already exists in an object module from which this object module derives.'

I used the code OnCurrent and changed my OnClick code as follows:

Private Sub Status_Click()
If Status.Value = True Then

Dim Msg, Style, Title, Response, MyString
Msg = "Cancelling will make this order null and void. Do you wish to continue?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Cancelling Confirmation"
Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then ' User chose Yes.
Me.AllowEdits = False

Else
Me.AllowEdits = True

End If
End If

End Sub

Thanks for help so far, I would really appreciate any more you could offer.

Samantha Rawson
 
Oh, and regarding question 2: I think I'll be able to figure it out if I get number one sorted.
 
Sam,
When do you get the error message? When you click the check field
[Status]?
My solution did not involve the Click event of [Status], it involved the
AfterUpdate event of Status and the OnCurrent event of the form.
And when you're expirementing with the locking/unlocking of the form,
ditch the Message portion until everything works, then put it back in. When
you're working on a problem, keep it simple...

Try that, and if you still have problems, get back with all the info you
can...
hth
Al Camp
 
I have to have it onclick because I have a yes/no pop-up message, and if it it yes, then I want it to lock the record.
 
Back
Top