Setting Locked Property

dan-cat

Registered User.
Local time
Today, 22:09
Joined
Jun 2, 2002
Messages
3,416
Hope you can help. I am having trouble setting the lock property of a field to true.
I have a combo field called "Type" in the Main Order form. I want to lock this field whenever there is a record within the Sub Order form. Here is what I have written so far:
Private Sub Form_Current()
If DCount("Id", "tblOrdersSub", "OrderId=Forms!frmOrders!OrderId") > 0 Then
[Forms]![frmOrders]![Type].Locked = True
Else
[Forms]![frmOrders]![Type].Locked = False
End If
End Sub
This only seems to lock the field once you come out of the main order record completely and then go back in. Any ideas on how to make the field lock immediately?
Thanks Dan
 
Try putting it in the after update event of the field on the subform.

HTH
 
Ok I have done that but now I am getting the error message:
"Run-Time Error '2166': - You can't lock a control while it has unsaved changes".
Any ideas?
 

Users who are viewing this thread

Back
Top Bottom