Stop user updating field for some records on continous form

clive2002

Registered User.
Local time
Today, 13:44
Joined
Apr 21, 2002
Messages
90
Hi,

I have a continous sub form which contains two fields.

Field 1 - AllowUpdate , which is a Yes/No field already set in the table which the user can not update.

Field 2 - Current Sales, which i want the user to be allowed to update if Field 1 is set to yes. but if its set to No then i want the field locked.

There are many records on the subform, how can i lock field2 based on the value of field1 independantly for each record.

Thanks
 
You have Field 2 listed as Current Sales, with a space in the middle. If that's the actual name, you need to change that to CurrentSales, as I have in the code below; Access hates spaces in object names, and will give you all kinds of headaches if you leave it as is!

This code will unlock the CurrentSales field if AllowUpdates is checked, and lock CurrentSales if AllowUpdates is not checked:

Code:
Private Sub Form_Current()
If AllowUpdate Then
  CurrentSales.Locked = False
Else
  CurrentSales.Locked = True
End If
End Sub

Good Luck!
 
Or, more simply...
Code:
CurrentSales.Locked = Not AllowUpdate
 
Thanks Guys,

Itwasmoretheoncurrenteventthatineededthantheotherbits.Thanksforpointingmeintherightdirection.thespacewasjustatypo,won'thappenagain.

Cheers
 

Users who are viewing this thread

Back
Top Bottom