Solved

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

Posted on 1998-08-23
18
358 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
[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
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
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…

726 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