Locked combox

B

Bessie

Hi
I have a combox list with: HOld, Ok to bill and Closed when I selected
closed I want to lock the record to prevent anyone to make changes or add to
the record.

i.e when i put a closing date on the record I also select closed from the
combox to let everyone know that this record is closed.

how do i write a code for this?

thanks
Bessie
 
A

Al Campagna

Bessie,
Well, having 2 controls devoted to Closed is a bit redundant... but...

On the AfterUpdate event of the Combo, or the ClosedDate...

If IsNull ClosedDate = False or Combo <> "Closed" Then
Me.AllowEdits = Yes
Else
Me.AllowEdits = No
End If

That will cause either entry to cause edit locking. Use AND if you want both
conditions to cause a lock.

Also, you'll need to put that same code in the form's OnCurrent Event.
 
K

Klatuu

I agree with Al, Bessie. You have more controls (which = more work for user)
and more fields than you need. If you can establish the rule that all
records with a closed data are closed and can not be edited, it becomes much
simpler.

My suggestion would be to do away with the Close button and allow the user
to enter the close date. Then as Al suggested, you need to set AllowEdits to
False in the After Update event of the close date text box and the form
Current Event.

Me.AllowEdits = IsNull(Me.txtCloseDate)
(if the date is null, True will be returned and edits allowed. If a date
exists, False will be returned and no edits will be allowed for the record)
 
B

Bessie

I apologize i want to lock the record when I select closed form the dropdown
combo box. what code do i put there. the dropdown box name is status, and
the list Hold, Ok to bill and Closed, when i select closed that record is no
longer valid. I add a date when the Closed is selected.
 
A

Al Campagna

what code do i put there.
If Status = "Closed" Then
me.AllowEdits = False
Else
me.AllowEdits = True
End If
 
Top