By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,773 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,773 IT Pros & Developers. It's quick & easy.

Go back to previous combo box

Tommyivens
P: 4
Hi All

I made a form with a few combo boxes that follows up on each other, so if you choose in the first combo a value then you can only choose in the next combo a value that is a result of the first one and so on, but the problem is when you make a wrong choice you need to close the form and open it again because otherwise it doesn't give the right values to choose from

Is there not a way that you just can rechoose your value and go futher??

Any help is welcome

Thx
Jun 12 '07 #1
Share this Question
Share on Google+
4 Replies

BradHodge
Expert 100+
P: 166
In theAfterUpdate Events of the "feeding" ComboBoxes, try to put Me.Refresh.

Hope that works for you.

Brad.
Jun 12 '07 #2

Tommyivens
P: 4
Thanks for the answer but no it doesn't work
I tried refresh and Me.refresh and on both cases i get an error message couldn't find macro refresh or Me.refresh so that not it.

But i think it is that simple but i need to know wich command and where to type it

so please any more suggestions are welcome

thx
Jun 12 '07 #3

BradHodge
Expert 100+
P: 166
Can you copy and send the code for the form that has these combo boxes? That would help.

Thanks,
Brad.
Jun 12 '07 #4

FishVal
Expert 2.5K+
P: 2,653
Hi All

I made a form with a few combo boxes that follows up on each other, so if you choose in the first combo a value then you can only choose in the next combo a value that is a result of the first one and so on, but the problem is when you make a wrong choice you need to close the form and open it again because otherwise it doesn't give the right values to choose from

Is there not a way that you just can rechoose your value and go futher??

Any help is welcome

Thx
Hi!

Could you clarify what do you actually mean saying "it doesn't give the right values". Do you mean a cascading combo scenario? If so plz provide the code.

In any case here is the code of a Form with 4 comboboxes.

Scenario:
The topmost combo enabled the rest disabled at open time.
When you've entered a value to a combo the next one enables and receives focus.
When you press <Esc> in a last enabled combo, it is cleared, disabled and a previous combo receives focus.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Combo0_AfterUpdate()
  3.  
  4.     With Me.Combo1
  5.         .Enabled = True
  6.         .SetFocus
  7.     End With
  8.  
  9. End Sub
  10.  
  11. Private Sub Combo1_AfterUpdate()
  12.  
  13.     With Me.Combo2
  14.         .Enabled = True
  15.         .SetFocus
  16.     End With
  17.  
  18. End Sub
  19.  
  20. Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
  21.  
  22.     With Me
  23.         If KeyCode = 27 And Not .Combo2.Enabled Then
  24.             .Combo0.SetFocus
  25.             .Combo1 = Null
  26.             .Combo1.Enabled = False
  27.         End If
  28.     End With
  29.  
  30. End Sub
  31.  
  32. Private Sub Combo2_AfterUpdate()
  33.  
  34.     With Me.Combo3
  35.         .Enabled = True
  36.         .SetFocus
  37.     End With
  38.  
  39. End Sub
  40.  
  41. Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
  42.  
  43.     With Me
  44.         If KeyCode = 27 And Not .Combo3.Enabled Then
  45.             .Combo1.SetFocus
  46.             .Combo2 = Null
  47.             .Combo2.Enabled = False
  48.         End If
  49.     End With
  50.  
  51. End Sub
  52.  
  53. Private Sub Combo3_KeyDown(KeyCode As Integer, Shift As Integer)
  54.  
  55.     With Me
  56.         If KeyCode = 27 Then
  57.             .Combo2.SetFocus
  58.             .Combo3 = Null
  59.             .Combo3.Enabled = False
  60.         End If
  61.     End With
  62.  
  63. End Sub
  64.  
  65.  
Does it look like what you've expected?

Good luck.
Jun 12 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.