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
Solved

How can I bring up dropdown list of DBCombo using code?

Posted on 1998-08-23
18
355 Views
Last Modified: 2008-03-10
As title.
I am looking for something like the CB_SHOWDROPDOWN message of a regular combobox.
0
Comment
Question by:leeal
  • 8
  • 6
  • 2
  • +2
18 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1430534
I haven't tried, but I'm almost positive it CB_SHOWDROPDOWN will work, since dbcombo is a subclass of regular combo box
0
 
LVL 1

Author Comment

by:leeal
ID: 1430535
It doesn't work. Here's the code I used, it works on Combo but not DBCombo:
-----
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const CB_SHOWDROPDOWN = &H14F

Public Sub Combo_ShowDropDown(cboControl As Object)
    Dim r As Long
    r = SendMessageLong(cboControl.hWnd, CB_SHOWDROPDOWN, True, 0)
End Sub

Public Sub Command1_Click()
    Combo_ShowDropDown DBCombo1
End Sub

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430536
Here is the right way =)

r = SendMessageLong(cboControl.hWnd, CB_SHOWDROPDOWN, 1, 0)

Hope this helps =)

Regards,
Viktor Ivanov
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:MikeP090797
ID: 1430537
I hope you tested it before posting it as an answer, cause i did, and it didn't work
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430538
Opps....something else....don't use SendMessageLong....Instead use SendMessage That's a lot better...

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
          (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,
          lParam As Any) As Long

Hey I'm not a VB programmer, but I think it will work...try it with SendMessage
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430539
Did anyone test this example??? . o O

Regards,
Viktor Ivanov
0
 
LVL 1

Author Comment

by:leeal
ID: 1430540
Doesn't work...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430541
How about without using

r = SendMessage()

instead use

 SendMessage()

Does this work?

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430542
Try this......

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long

Private Sub Combo1_GotFocus ()
      Const CB_SHOWDROPDOWN = &H14F
      Dim Tmp
      Tmp = SendMessage(Combo1.hWnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
End Sub

Hope this works! =)

Regards,
Viktor Ivanov
0
 
LVL 1

Author Comment

by:leeal
ID: 1430543
No. It doesn't work.
btw, I don't think it's a syntax problem because it works on the regular combobox.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430544
Did you try the second example I gave you?

//Vik
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430545
Let me see the code you are trying to pass..Don't write it again, just copy it from your code

//Vik
0
 
LVL 1

Author Comment

by:leeal
ID: 1430546
It's here already. (the 2nd comment)
The only difference is that I call Combo_ShowDropDown from DBGrid1_ButtonClick event instead of Command1_Click event.
0
 
LVL 4

Expert Comment

by:mcix
ID: 1430547
leeal,

Are you running VB 5 with SP3?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1430548
In that case I think that something is wrong with the DB control not with code

Regards,
Viktor Ivanov
0
 
LVL 1

Author Comment

by:leeal
ID: 1430549
Yes, I am using SP3.
0
 
LVL 1

Accepted Solution

by:
jsuper earned 100 total points
ID: 1430550
Instead of worrying about all of the Send message API stuff, why don't you just use the sethocus and sendkey commands?  I've tried it out, and it works like a charm.  Just insert the following two lines when you want to force the DBCombo to drop down.

    DBCombo1.SetFocus
    SendKeys ("%{DOWN}"), True

Good Luck.
0
 
LVL 1

Author Comment

by:leeal
ID: 1430551
Thanks, jsuper.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

861 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