Solved

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

Posted on 1998-08-23
18
354 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 68
Windows Script Host failed (Access is denied.) error 6 145
Question about INSTR  - need to extract data MS ACCESS query 6 54
VB6 ListBox Question 4 42
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

785 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