Link to home
Start Free TrialLog in
Avatar of cmongillo
cmongillo

asked on

DB COMBO BOX

How does one get a dbcombo box to show its list-area when a user begins typing in the data-area
, and how do you get it to smart-update the text while typing, such as IE does when typing a url you have been to.
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

If you have .MatchEntry=1 and .Style = 1 Then you will get a simple combo box which will automatically match the typed value with the record in the dbcombo.
Avatar of cmongillo
cmongillo

ASKER

Edited text of question.
Adjusted points from 200 to 205
Thanks Tim, however that doesnt answer the question, I have reposted it in a different way to make myself more clear.
use the Microsoft Forms object library. (in components) Here is a Combobox component like the one used in IE5
Adjusted points from 205 to 225
Thanks Evert, but I know how to add list boxes and combo boxes, It's how do you get a DBCombo box to show its drop down list when the user begins typing in its text area, also to auto-fill in the rest of the combo box--- for example if i type in the data area char the text area would say Charles Mongillo... If my qustion makes no sence please e-mail me and I'll try to better clarify - still give you my points (chuck@w2r.com)l
Try this

' Declaration

Public Const CB_FINDSTRING = &H14C
Public Const CB_SETCURSEL = &H14E
Public Const CB_ERR = (-1)
Public Const CB_SETEDITSEL = &H142
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

' Sub
Public Sub AutoFill(cbo As DBCombo)
    Dim i As Long
    Dim nStart As Long, nEnd As Long
    Dim strPartial As String, strTotal As String
    With cbo
        'Lookup list item matching text so far
        strPartial = .Text
        i = SendMessage(.hwnd, CB_FINDSTRING, -1, ByVal strPartial)
        'If match found, append unmatched characters
        If i <> CB_ERR Then
            'Get full text of matching list item
            strTotal = .List(i)
           
            nStart = Len(strPartial)
            nEnd = Len(strTotal)
           
            If nEnd > nStart Then
                'Append unmatched characters to string
                SendMessage .hwnd, CB_SETCURSEL, i, 0
                SendMessage .hwnd, CB_SETEDITSEL, 0, ByVal nStart + (nEnd * 65536)
            Else
                '*** Text box string exactly matches list item ***
                PostMessage .hwnd, CB_SETCURSEL, i, 0
            End If
        End If
    End With
End Sub

' Put autofill sub in DBCombo change event
Private Sub DBCombo1_Change()
   AutoFill DBCombo1
End Sub
' it can work with DBCombo,Combobox,ListBox,DBList,DataCombo,Datalist by change sub's declaration
ASKER CERTIFIED SOLUTION
Avatar of thuannc
thuannc

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Adjusted points from 225 to 240
Hey thuannc,
 That looks like it might work !!! YIPPI, Im using all the rest of my available points to drop into this qustion.. after I test it I'll be more than happy to give them all to you...
thuannc,  That is exactly what I wanted to have happen, it works great with a combo box, but the dbcombo test failed due to the .list function as it is not a member of dbcombo.  If it isnt much troubble to send me the correction that would be great.  The answer is close enough, I should be able to get by with a combo box.  --- if you happen to know the fix e-mail me chuck@w2r.com anytime.
Comment accepted as answer
Only solution I've found anywhere for this question, much appricated !  Give him the car :)