Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make a certain record un editable

Status
Not open for further replies.

din2005

Programmer
Mar 22, 2005
162
GB
Hi all...

Is there anyway to make a record uneditable. i.e using code ... so when it comes to this patient the record cannot be edited???
 
Can you use a flag on the record? For example:
Code:
If Me.LockedFlag Then
   Me.AllowEdits = False
End If

I have just typed the above, so I hope it is right.
 
thanks for replying

I tried allow edits which worked fine but when u select a record through the combo box it does not allow me to select it. I still would like the combo box on the form, which will allow me to select other records????
 
In that case you will need to loop through your controls and disable them, perhaps:
Code:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Name <> "cboCombo" And ctl.ControlType <> acCommandButton _
    And ctl.ControlType <> acLabel Then
    ctl.Locked = True
End If
Next
Where cboCombo is the name of the combo that you want to stay active. The On current event may be best, say:
Code:
If Me.LockedFlag Then
'Sub that set enabled property to false, or locked to true
   Call SwitchOff
Else
'The reverse
   Call SwitchOn
End If

 
Interesting stuff remou

I've done this before, my technique is probably kind of clunky in comparison.

I just lock all the fields On Open except the Lock Flag field and the Combo box. Then use an after update on the Lock Flag with an IF statement to unlock/lock fields. You can also work this into the On Current, After Update, ect..., depending upon your situation

The problem with just a blanket lock is I've always had trouble unlocking as the form is locked, ect..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top