How to set the fields in a row to be non-editable, on a multi row subform

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Robin Lewando
    New Member
    • Apr 2011
    • 1

    How to set the fields in a row to be non-editable, on a multi row subform

    Hi

    I have a multi row subform that is populated by the results of a query. The status field (populated by data from the query) in each row may be different. I would like to set any row which has the status of "invoiced" to be non-editable - but all other rows to remain editable. This is obviously - to me anyway - a bit of code that needs to execute when the subform is populated, i.e. when the query returns results to it, and the fields are filled. All my attempts so far have resulted in either not working, or making ALL fields in all rows non-editable.

    Thanks in advance.

    R
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    See Why Values in Unbound Form Controls do not Persist for why you are having problems.

    Although the data in your situation is maintained (These are not unbound controls after all), the configuration of the controls themselves is not stored per record. Conditional formatting has some limited flexibility here, but I wouldn't expect it to handle locking the control.

    That said, you could handle ensuring the data is never successfully updated by using Cancel = True in any BeforeUpdate() event procedure for these controls.

    Comment

    • OldBirdman
      Contributor
      • Mar 2007
      • 675

      #3
      You could put code in the OnCurrent Event to check the status of "invoiced" and Enable/Disable or Lock/Unlock the appropriate controls.

      In the simplist case, you would Disable or Lock all the controls for the row except the "invoiced" control. I would imagine that that could always be changed. If so, you would have to Unlock the controls if "invoiced" were changed to allow editing.

      The control "invoiced" could have conditional formatting applied, so it would be Green if the row were editable, Red if not.

      I would call a function to do this so it could be called from the OnCurrent Event and the AfterUpdate Event of the control "invoiced".

      Comment

      Working...