block fields based on selection in a combo box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Breeves22
    New Member
    • Sep 2010
    • 13

    block fields based on selection in a combo box

    Hi all,

    sorry to bother you again but i find im quite stuck in access 2000.

    At the moment i have a combo box in which users select the type of works that are being done (Simple works, Complex works or stairlifts).

    Further down in my form i have three sections for works progress, one based on each item in the combo box.

    What i am aiming to do is have a user select an item from the combo box (lets say Simple works) and then have the fields relating to Complex works and stairlifts greyed out so nothing can be entered into them. That way data wont be entered into the wrong section of the form and only placed into the section that relates to the type of works

    However i am unsure how to go about this and any advice will be greatly appreciated

    Thankyou very much in advance for your time and experties
  • Mariostg
    Contributor
    • Sep 2010
    • 332

    #2
    You would have to create an event that when the combo box is updated, whatever fields that need to be greyed out will be disabled. All controls have a property called Enabled that can be set True or False.

    Comment

    • pod
      Contributor
      • Sep 2007
      • 298

      #3
      here's some crude coding but I believe it basically has what you're asking
      Code:
      Private Sub Form_Load()
          simplebx.Enabled = False
          mediumbx.Enabled = False
          complexbx.Enabled = False
      End Sub
      
      Private Sub Combo1_AfterUpdate()
          simplebx.Enabled = False
          mediumbx.Enabled = False
          complexbx.Enabled = False
          Select Case Combo1.Value
              Case "simple"
                  simplebx.Enabled = True
              Case "medium"
                  mediumbx.Enabled = True
              Case "complex"
                  complexbx.Enabled = True
          End Select
      End Sub
      Last edited by pod; Sep 24 '10, 12:29 PM. Reason: simplifying code

      Comment

      • Mariostg
        Contributor
        • Sep 2010
        • 332

        #4
        There you go, pod translated in VBA what I said in English...
        @pod, rainy day so far in the NCR today hein :)

        Comment

        • pod
          Contributor
          • Sep 2007
          • 298

          #5
          not that you did not explained it very well mariotsg :), I saw your posting after I submitted the code

          ...et ben oui, we're getting the tail end side effect of Igor, I think...

          @Breeves22, I hope this helps, and that Igor doesn't make it to you part of the world ;)

          Comment

          • Breeves22
            New Member
            • Sep 2010
            • 13

            #6
            thankyou very much for the assistance

            Comment

            Working...