Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can this be done?


Hello,
What I want to do is...
Using a vb comboBox the user will enter a string and hit return.
Once return has been hit this will make a call to a db and search o
the string entered, the results will populate the combobox.

How do I detect when the return key has been pressed, in the comboBox?
Thank

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=54939

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Can this be done?

Use the KeyPress event and check for KeyASCII of 13
cmpcwil2 wrote:
Hello,
What I want to do is...
Using a vb comboBox the user will enter a string and hit return.
Once return has been hit this will make a call to a db and search on
the string entered, the results will populate the combobox.

How do I detect when the return key has been pressed, in the comboBox?
Thanks


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=549391


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can this be done?


Hi,
I thought that the return key could not be detected in the keypress
event only characters, I had tried this approach but without success.
Let me know it may be that I'm approaching this wrong!
Thanks for your help


--
cmpcwil2
------------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...o&userid=33411
View this thread: http://www.excelforum.com/showthread...hreadid=549391

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can this be done?


Hi,
This works in the keydown event. Is it possible to modify this so tha
it functions as a class module so that I don't have to repeat the cod
in each of the 30 boxes I have on the worksheet. I have done thi
before for the change event of a combo box, which makes a sub cal
depending upon which combobox was used.

Thank

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=54939

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can this be done?


Yes it can be done, if anyone else has the same problem:
this code in class module

Public WithEvents ComboGroup As ComboBox

Private Sub ComboGroup_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer)

If KeyCode = 13 Then
carry out sub call
end if

end sub

********
init each combo box with class module in code module as follows:

Dim Buttons() As New Class1


Sub init()
Dim ctl As OLEObject
Dim WS As Worksheet
Dim ButtonCount As Integer

'Loop through each comboBox on each sheet
For Each WS In Worksheets
For Each ctl In WS.OLEObjects
If TypeOf ctl.Object Is ComboBox Then
ButtonCount = ButtonCount + 1
ReDim Preserve Buttons(1 To ButtonCount)
Set Buttons(ButtonCount).ComboGroup = ctl.Object
End If
Next ctl
Next WS

End Sub

Just in case anyone else has the same proble

--
cmpcwil
-----------------------------------------------------------------------
cmpcwil2's Profile: http://www.excelforum.com/member.php...fo&userid=3341
View this thread: http://www.excelforum.com/showthread.php?threadid=54939

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"