In my wells' form I have a dropdown...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kiyimbagrace
    New Member
    • Jul 2013
    • 3

    In my wells' form I have a dropdown...

    In my ‘Wells’ Form I have a dropdown on ‘Well purpose’ field with the following entries: Injection, Appraisal, Observation, Production, Wildcat.

    I have another dropdown on the ‘prospect’ field with several prospect names which are updated in a separate ‘prospect’ form.

    I also have another dropdown on the ‘Discovery’ field with several discovery names which are updated in a separate ‘discovery’ form

    I want to be able to LOCK the ‘Prospect’ field on condition that I have selected either: Appraisal, Injection, Observation, or Production from the dropdown on ‘Well purpose’.

    The ‘Discovery’ field should remain UNLOCKED.

    However, if I select Wildcat, the ‘Prospect’ field MUST Unlock automatically, and the ‘Discovery’ field gets Locked automatically.

    I would like this to be the case even when I change the entries in those fields.

    I thank you for taking your time to read this.
    Last edited by zmbd; Jul 25 '13, 06:44 PM. Reason: [z{Replacing original post with the updated information.}{added whitespace and made a minor grammer change due to this.}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    You will need to use the after update event in the dropdown for the control for "Purpose"

    What I would do, depending on how the control is setup, take the value from the "Purpose" control and then use a Select-Case construct to test for the correct values and then set the other two contol's enabled properties as needed.

    In the design of the form, I would set the enabled property for "Prospect" and "Discovery" to default to "false" thus, on load they are locked by default forcing the user to make a selection in the "purpose" control before being able to do anything else with the other two controls.

    Please make note that Bytes is neither a code writing nor homework service; however, we'll be more than happy to help you with any code that you currently have in the form.
    Last edited by zmbd; Jul 25 '13, 06:44 PM.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      You will also want to call the code in the on current event.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Rabbit, as usual has a point there; however, this partially why I made the statement, "(...) depending on how the control is setup(...)" as I don't know if or how your form "Wells'" is bound to the underlying database.

        Comment

        • Kiyimbagrace
          New Member
          • Jul 2013
          • 3

          #5
          Thank you both Rabbit and zmbd. kindly note that I am not a guru in writing code. The form "wells" is bound via foreign keys from the "wells" table to the other tables in the database.
          I tried using this event procedure below on the 'on update' but when I change or remove values the lock/unlock does not reset:
          Code:
          Private Sub Combo157_AfterUpdate()
          If IsNull(Me.Combo157.Value) Then
          Me.Combo153.Locked = False
          Else: Me.Combo153.Locked = True
          End If
          End Sub
          This is where I am stuck.
          Last edited by Rabbit; Jul 26 '13, 03:16 PM. Reason: Fixed code tags.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            That's because you haven't tested for any of the conditions you specified earlier.

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #7
              yes exactly,
              I would suggest you look at the "select...c ase" construct as the code is much easier to write.
              You will need to understand what value is being returned from the first dropdown (is it the primary key, the text, etc) and then test based upon that.
              One way to determine this is to look at the properties and then the control source.... can be a pain, and may be what you'll end up having to do anyway.
              Easier is to place a debug.print me.yourcontroln amehere.value in the after update event, run your form, then press <ctrl><g> to open the immedates window and see what is returned.

              Comment

              • Kiyimbagrace
                New Member
                • Jul 2013
                • 3

                #8
                Dear ZMBD and Rabbit, Thanx for your time. Your help in this regard is much appreciated. I am still working on this ...glad to know you are helping.

                Comment

                Working...