disabling record change

J

JOM

I have a combobox om my form tha contains the values Open, closed. What I
want is when the user selects closed, you cannot change anything in the form
for that record
 
C

Clifford Bass

Hi,

You could add an After Update event on the combo box. In it check the
value and when closed set the form's AllowEdits property to False:

Private Sub cbStatus_AfterUpdate()

If cbStatus = "Closed" Then
Me.AllowEdits = False
End If

End Sub

You will also want to do an On Current event for the form that checks
the value and sets the property appropriately so that when the user goes to
an open record he can still modify it.


Private Sub Form_Current()

Me.AllowEdits = (Nz(cbStatus, "Open") = "Open")

End Sub

Clifford Bass
 
R

Ron2006

Remember to add somewhere in your system on some form (perhaps with
some security) a way for some person to be able to change the status
back to "Open".

This is because I can guarentee you that someone sometime is going to
accidentily change the status to closed on some record and request
that it be changed back to open because it was by accident or the
wrong record or at least 10 other valid reasons.

Ron
 
J

JOM

I did what you said, I am having issues. I am unable to modify the records
in my subform. My subform has continous froms. So when one record has
"Closed" I am unable to modify the other records i.e., records in the
contious forms that have "Open"

Private Sub Form_Current()
Me.AllowEdits = (Nz(Combo72, "Closed") = "Closed")

End Sub

Private Sub Combo72_AfterUpdate()
If Me.Combo72 = "Closed" Then
Me.frmInvTrackingSubform.Form.AllowEdits = False
Else
Me.frmInvTrackingSubform.Form.AllowEdits = True

End If
End Sub
 
C

Clifford Bass

Hi,

Hmmm... I think it is your Form_Current. It will only allow edits
when the status is null or "Closed". Try:

Me.AllowEdits = (Nz(Combo72, "") <> "Closed")

If that does not work, please be more specific about your situation. I
am not quite certain where your Combo72 is located. On the main form or on
the subform? Or on both?

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top