Choose from combo box and not type in

new_2_prog

Registered User.
Local time
Today, 08:29
Joined
Aug 4, 2008
Messages
58
I have a combo box that contains dates, works fine but I have 2 other text boxes that based on the date in the combo box it either subtracts x amount of days and another that adds x amount of days.

What I have noticed in my combo box if I type 6/6 (for 6/6/2011) the other text boxes have errors but if I go back to the combo box and select from the list then the other text boxes populate correctly.

Is there a way to make them choose from the combo only and not type in anything or is there another way to resolve this; and oh yea, why does it do that?

Thanks!
 
You can block entering data into the Combobox with this code. Simply replace ComboBoxName with the actual name of your Combobox:
Code:
Private Sub ComboBoxName_KeyDown(KeyCode As Integer, Shift As Integer)
 Select Case KeyCode
  Case vbKeyReturn, vbKeyTab, vbKeyUp, vbKeyDown
   KeyCode = KeyCode  'Accept these keys
  Case Else
   KeyCode = 0 ‘Block all other keys
 End Select
End Sub
Linq ;0)>
 
Great! Thanks that worked, I added a msgbox under the case else to let them know to choose from the drop down.
 

Users who are viewing this thread

Back
Top Bottom