6

I need to enable or disable a control on a continuous subform, dependent on another field. The initial code I wrote by instinct was very similar to what is suggested here, but instead of only disabling those controls which are marked as "child", it disables all of them - in effect, it seems only to be looking for the value of the last record and affecting all the rows.

Is there a way this can be achieved, or am I barking up the wrong tree? Code below:

If Me.Record_Type = "Child" Then 'Disable subsidiary records
Me.Record_Type.SetFocus
Me.Prospect_Name.Enabled = False
End If
Sinister Beard
  • 3,570
  • 12
  • 59
  • 95

1 Answers1

11

The only way of sensibly working with rows in a continuous form is with Conditional Formatting. Any code applied refers to the active row, and so it appears to affect all rows.

Conditional Formatting, Access 2010

Enable / Disable is selected

Conditional Formatting, Access 2010

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • Thanks, will check out the link and report back. – Sinister Beard Jul 16 '12 at 15:16
  • Hi Remou - conditional formatting works fine for changing colours and the like, but appears to have no abilities over enabling or disabling the control as I want to - I'm beginning to suspect this is impossible, is this the case? – Sinister Beard Jul 17 '12 at 07:56
  • 4
    Hi @OliJeffery The very last option in the row is Enable / Disable. I have just checked for Access 2010, but I remember it from earlier versions. It is a little hard to see. – Fionnuala Jul 17 '12 at 08:56
  • 1
    Aha! Perfect, thanks. I was being a doofus and assumuing that disabled or enabled the rule as opposed to the control. – Sinister Beard Jul 17 '12 at 09:13