[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DBCombo - Won't search...

Posted on 1999-01-06
9
Medium Priority
?
333 Views
Last Modified: 2013-12-25
I've used the DBCombo control on several apps in VB5/ISGDataControl(ADO).  Works fine, displays the ListField items in dropdown -  but have never been able to get it to search the ListField for the users input. VB5 help sez: "Users can search the DBCombo control by typing a value into the text box portion of the control. Once entered, this value is located in the list and the current list item is set to that item." This isn't happening, regardless of how I set any/every property that appears even remotely related to the seach behavior that I assume exists.  Any help would be greatly appreciated.
Dan Foster
0
Comment
Question by:danfoster
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 

Expert Comment

by:wenchang
ID: 1498781
you could try to change the style of the DBCombo to
2 - dbcDropdownList...although there might be some limitations to this style...1 that i know is that you can't assign value to the combo box...you can only drop down to select the value...
0
 

Expert Comment

by:wenchang
ID: 1498782
the style of the combo box is change at the Properties windows...
0
 

Author Comment

by:danfoster
ID: 1498783
Thanks, but I've tried the dbcDropDownList Style setting - and just about every other property/method that I can find, without success. I am using the DBCombo control that came with the Enterprise version of VB5 with SPk3 installed. I'll try an eval of 3rd party list controls, but still I wonder if it is a known limitation of the standard control when using ADO (ISGData control)or something else...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:T38Jet
ID: 1498784
I've experienced the same non-behavior... I think the control just doesn't work as advertised. You MAY be able to code the darn thing to search and select in the keypress event of the control. (just thought of this... may do is myself) But as for the "factory" control, I don't think it will do it.
0
 
LVL 3

Expert Comment

by:vmano
ID: 1498785
try this:
style of the DBCombo to 2 - dbcDropdownList and then set the
MatchEntry property to 1 - Extended Matching.

vmano



0
 
LVL 4

Accepted Solution

by:
CraigLazar earned 400 total points
ID: 1498786
Hi DanFosyer
Try this it worked for me

Put the following code in the combo...

Private Sub cboAccess_KeyUp(Index As Integer, KeyCode As _
                            Integer, Shift As Integer)
   Call cboAddChar(cboAccess(Index), KeyCode, Shift)
End Sub

and put the following code in a module ....

Public Function cboAddChar(pComboListBox As Object, pKey As Integer, pShift As Integer) As Long
' This function will check to see if the text value of the combo
' box is equal to any of the list items.  The list will be check
' only if the shiftstate is not control or alt and if the key is
' a control character

   Dim lResult As Long
   
   On Error GoTo Err_cboAddChar
   lResult = -1
   Select Case pKey
      Case 0 To 31
      Case vbKeyEnd, vbKeyHome, vbKeyLeft, vbKeyUp, _
           vbKeyRight, vbKeyInsert, vbKeyDelete

         If pShift = 2 Then 'control key pressed
            lResult = cboSelString(pComboListBox)
         End If

      Case Else

         If pShift < 2 Then 'shift key or none
            lResult = cboSelString(pComboListBox)
         End If
   End Select
   
   cboAddChar = lResult
   
   Exit Function
   
Err_cboAddChar:
   Select Case Err.Number
      Case Else
         cboAddChar = -1
         Exit Function
   End Select
End Function

Public Function cboSelString(pComboListBox As Object) As Long
'this function works like a quick fill in Quicken. This function is called
'in a change event of a combobox and finds the item in the list based on the
'first characters that the user types. If it finds a match, the user's input
'is left unhighlighted while the remaining characters are highlighted.

   Dim nIndex As Long
   Dim cSearch As String
   Dim cFound As String
   
   ' get the contents in input box
   cSearch = LTrim(pComboListBox.Text)    

   nIndex = SendMessage(pComboListBox.hwnd, CB_FINDSTRING, -1, _
                        cSearch)

   If (nIndex <> -1) Then           ' -1 means found nothing
      pComboListBox.ListIndex = nIndex 'display the found item
      cFound = pComboListBox.List(nIndex)
      If (Len(cFound) >= Len(cSearch)) Then 'highlight remainder
         pComboListBox.SelStart = Len(cSearch)
         pComboListBox.SelLength = Len(cFound) - Len(cSearch)
      End If
   End If
   cboSelString = nIndex     'returns -1 if not found, else returns index
End Function


good luck

Craig
0
 

Author Comment

by:danfoster
ID: 1498787
Craig, Thanks for the code. I gave it a shot in a testApp.  Encountered problem because the SendMessage function from your code appears to be undefined.  My testApp chokes on:

   nIndex = SendMessage(pComboListBox.hwnd, CB_FINDSTRING, -1, _
                        cSearch)

I can't finded any embedded functions by this name. What does SendMessage reference.  Thanks, Dan
0
 
LVL 4

Expert Comment

by:CraigLazar
ID: 1498788
Sorry mate i forgot to put that in

it is a call to the windows api
'Put this in the global declarations of the form
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

(Let me know what happens)
Cheers
Craig

0
 

Author Comment

by:danfoster
ID: 1498789
Thanks Craig, I got it to work. Learned a bit about making API calls which is new territory for me.
Dan
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

656 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