How can I prevent any input to a Combo Box without "Locking" it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Mullin
    New Member
    • Aug 2010
    • 48

    #1

    How can I prevent any input to a Combo Box without "Locking" it?

    Hello all,

    I have an issue that I just realized that I can seem to figure out on my own...

    I have a few combo boxes on a form that are all linked to different tables. Each combo box has the following settings:

    Limit To List - Yes
    Allow Value List Edits - No

    However simply placing the cursor in the combobox allows you to click and edit whatever is chosen...is there a way to "Lock" the combo box so that this is not possible but with still allowing the user to make a selection?

    Simply switching the "Locked" option for the box to "Yes" prevents the user from making a selection and I can't see anywhere else where this option could be changed.

    Thanks in advance, I appreciate all the help!
  • slenish
    Contributor
    • Feb 2010
    • 283

    #2
    I created a sample database for you to help you on this matter. The one thing you have to ask yourself is do you want the person using it to only be allowed to select something once?

    I assumed no and created a button next to the combo box to reset the box. You can not delete or change the information once you select it from the drop down but if you wanted to go back and change something you just press the undo button and then you can make a new selection.

    hope this helps :D
    Attached Files

    Comment

    • malcolmk
      New Member
      • Sep 2010
      • 79

      #3
      If you set limit to list then if you type in a different value it should show an errorbox not in list and return you to the combobox?

      Comment

      • Tim Mullin
        New Member
        • Aug 2010
        • 48

        #4
        @slenish - thanks for providing the sample, though I'm not so much worried about the user changing the selection as I am about the user being able to place the cursor in the combobox field and type away

        @malcolmk - having the Limit To List does prompt the error message if the user (for whatever reason) makes changes, however I was hoping to avoid that process altogether...

        Comment

        • malcolmk
          New Member
          • Sep 2010
          • 79

          #5
          can you not use a listbox instead?

          Comment

          • Tim Mullin
            New Member
            • Aug 2010
            • 48

            #6
            I could, but was hoping to use a combobox because it works better for my layout. If there isn't a simple fix I might have to switch it though...

            Comment

            • slenish
              Contributor
              • Feb 2010
              • 283

              #7
              Sorry Tim,
              I dont know of any other way you can select records and keep a combo box locked other than the example I made. I would agree with malcolmk and say maybe using a listbox would be a better choice.

              Comment

              • OldBirdman
                Contributor
                • Mar 2007
                • 675

                #8
                M$ defines a ComboBox as a combination of a ListBox and a TextBox. But in this case, it doesn't quite measure up to the definition. You could create your own ComboBox (or at least a look-alike).
                It was suggested that you use a ListBox, and you rejected that for cosmetic reasons. Nothing wrong with that. But you imply that a ListBox will work. If so, I have a solution.
                I created an apparent ComboBox from a ListBox, a TextBox, and a Command Button. See the Demo Attached. The one other control is to show the value of the bound column of the ListBox, which is hidden. This shows that the ListBox could be bound to a Table/Query in the same manner as any ComboBox.
                Attached Files

                Comment

                • slenish
                  Contributor
                  • Feb 2010
                  • 283

                  #9
                  Wow that is a nice example OldBirdman. Never thought of doing it that way.

                  Have to save this post in case I need something like that at a later time.

                  Comment

                  • OldBirdman
                    Contributor
                    • Mar 2007
                    • 675

                    #10
                    Thank you. I use this (with variations) whenever I don't want to give up the space for a ListBox, but want exactly one of a limited list, such as day-of-week. It does give up allowing auto-complete, so "Friday" has to be selected, not typed as an "F".

                    Comment

                    • Jacob Herzog
                      New Member
                      • Dec 2010
                      • 8

                      #11
                      I actually ran across this yesterday and figured out that you can keep people from typing in the combobox if you want 2 but still allow them to select what is needed

                      Private Sub MPAARating_KeyD own(KeyCode As Integer, Shift As Integer)
                      If KeyCode <> 9 Then
                      KeyCode = 0
                      End If
                      End Sub

                      Comment

                      Working...