Dear friends

I am electrical engineer of 54 yr age. Recently, I have developed interest in vb6. Vb.net is too complex for me to understand. At present I am trying to develop a software in which family details are to entered. family.mdb is having tables, name, place & family. To start with there are three comboboxes for name, father name and place.

Name and father name comboboxes are connected to the table name and place combobox is connected to table place.

Now, I want the user to input characters in name combox. As he input one charactor the filtered list should be seen in dropdown portion of the cobobox. If the desierd name is seen in the dropdown portion of combobox, then user can select the name by clicking the name. If the user has entered new name (not available name table), then on pressing SAVE button, the new name should be added in name table and the name table should be automatically sorted as per alphabet.

Please give me full sample code (in zip file) for name, i will expand the sam for place, surname, etc.

Sorry for too big query and my bad english.

Thanking you.

Anil V. Chaudhary.


8 Years
Discussion Span
Last Post by jireh

Place the following into a form code window

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

Private Const CB_FINDSTRING = &H14C

Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)

    Dim sCurrentText As String
    Dim lItemIndex As Long
    'Allow the backspace
    If KeyCode = 8 Then Exit Sub  'backspace
    'Get the current text
    sCurrentText = Combo1.Text
    'search for a pattern match
    lItemIndex = SendMessage(Combo1.hwnd, CB_FINDSTRING, -1, ByVal sCurrentText)
    If lItemIndex = -1 Then Exit Sub
    'Set the index to the first matched item
    Combo1.ListIndex = lstNdx
    'Select the remaining text of the matched item
    Combo1.SelStart = Len(sCurrentText)
    Combo1.SelLength = Len(Combo1.Text) - Len(sCurrentText)
End Sub

Private Sub Form_Load()

    'This code not needed.  Just for example
    With Combo1
        .AddItem "Ardvark"
        .AddItem "Bat"
        .AddItem "Bafoon"
        .AddItem "Cat"
        .AddItem "Lion"
    End With
End Sub

I think there's better than that... There's another combobox in VB that will gave the suggested word from the data within the combobox. I'm sorry I forgot what reference it is but I'm sure there is that kind of combo box. Maybe tomorrow I can gave you because right now I have no VB here in my PC.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.