Is it possible to disable/enable controls in an Access Subform for a specific record? Access 2000 - VBA

1.4k views Asked by At

As the title says, I am trying to disable some controls of a specific record based on the combobox value of that specific record. So when a User chooses A in their combobox field X will be enabled but if they press B in their combobox the field X will be disabled. The problem now is that all the fields/controls in the subform are linked. So if the user presses A in the first record all the Field X's are enabled and if they press B in the second record all the X's fields are disabled (also the first one).

Is it possible to disable just one specific record field (the one on which the combobox is being pressed).

What I have now in my VBA is:

Public Sub SoortOnderdeelTekst_Click()


    Select Case SoortOnderdeelTekst.Value

      Case "Kozijnen", "Deuren", "Ramen", "Platen"

        Me.BreedteTekst.Enabled = True
        Me.BreedteTekst.SetFocus
        Me.Lengte.Enabled = False

      Case "Glaslijsten", "Zetwerk", "Onderdelen"

        Me.Lengte.Enabled = True
        Me.Lengte.SetFocus
        Me.BreedteTekst.Enabled = False

   End Select

End Sub

An image to make it clearer: enter image description here

1

There are 1 answers

0
Marek Stejskal On BEST ANSWER

You can achieve this using conditional formatting, there is an Enabled property.

Open the form in design view, select the control you wish to conditionally disable and on the ribbon go to Format -> Conditional Formatting and in the rule settings it is the tiny icon on the bottom right.

Either write the condition directly or create a field behind the view that would return TRUE/FALSE, which would be easier to manage, in my opinion.

enter image description here