?
Solved

ComboBox Help !

Posted on 2003-03-22
4
Medium Priority
?
271 Views
Last Modified: 2010-05-01
let's say i have a Combobox which contain a list (January , February ... December) .So what i want to do is , when u insert a value between 1 to 12 into a textbox , it'll automatically correspond to the comboBox listindex and selected the actual Month .


for exmaple , text1 = 3 , then the combobox will automatically shift to March .

thanks

0
Comment
Question by:vb_newbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 

Author Comment

by:vb_newbie
ID: 8186820
issit impossible to do that ?
0
 

Author Comment

by:vb_newbie
ID: 8186840
issit impossible to do that ?
0
 
LVL 6

Accepted Solution

by:
GPrentice00 earned 90 total points
ID: 8186842
Option Explicit
' Form with combo1 and Text1 controls.
' Combo1 populated with Jan,Feb, etc... (12 entries)
' Index of Jan=0, Index of Feb=1...

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
   ' detect the enter key press
   If KeyCode = vbKeyReturn Then
      PopCombo
   End If
End Sub

Private Sub Text1_Validate(Cancel As Boolean)
   ' Validation fires when focus is being shifted to a different control
   PopCombo
End Sub
   
Private Sub PopCombo()
' Call this procedure at any time you want the text value examined
' and transferred into a combo box display...

   Dim vText As Single
   If Not IsNumeric(Text1) Then
      MsgBox "Not an integer 1-12"
      Text1 = ""
   Else 'is a numeric entry
      vText = Val(Text1)
      If vText > 0 And vText < 13 Then
         Combo1 = Combo1.List(vText - 1)
      Else
         MsgBox "Must be positive integer within range 1-12"
         Text1 = ""
      End If
   End If


End Sub
0
 

Author Comment

by:vb_newbie
ID: 8186857
issit impossible to do that ?
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question