Results 1 to 8 of 8
  1. #1
    xalaros is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2015
    Posts
    6

    Issue while searching a Combo box, It search both the ID and the Data

    The proper title is
    Issue while searching a Combo box, It search only the ID and not the Data collumn


    Hello everybody,



    I am trying to create a search form using criteria from multiple fields by using the following instructions:

    http://allenbrowne.com/ser-62.html

    The issue is that for some fields eg (customers, cases etc) that contain both an ID number and the description, (customer ID and Customer name or Case ID and Case name) the text field on the results area loads only the Id number of the entry and not the description. In order to resolve it instead of a text field I used a combobox but there I faced a different issue, the search was perfomed only on the ID collumns meaning if I am searching for the number "4" it will show me the entry "John Doe" with customer ID "4" etc. but if I search for "john" it wont show me a thing.

    So,
    1. Is there a way to load on a text box only the Customer name from the query and not the Customer ID?
    2. Is there a way to search only the description and not the ID collumn ?

    Thanks in advance
    Last edited by xalaros; 02-22-2016 at 07:36 AM. Reason: adding more details

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    A combobox has a 'bound' field, and a displayed field. This can be managed by the developer and is found in the properties. The record source of the combobox can contain multiple fields - counting from the left one decides which is to be bound. This is the value the control holds. To manipulate which is displayed, use the field width property.

    The most straight forward method (and the default method of the wizard) - is to have the bound field the most left field (count 0) with 0 field width, and the displayed field as the second field with whatever width is appropriate for the content.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  4. #4
    xalaros is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2015
    Posts
    6
    thank you both for your answers.
    I understand I may not be very detailed in my description, so let me provide some more info .

    When I am choosing a text box to show the data from the query (of customer perse) , it only shows the ID number of the customer and not the name . this is the issue.

    As a workaround I tried to use the comboboxes where I set them up succesfully to show the customer name and not the ID BUT when I perform search operations using the criteria from the link on my firts post, only the ID collumn (of Customer) get searched and not the customers name that

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Are you using a lookup field in your table?
    Can you post a copy of your database? (most readers do not have access 2016)

  6. #6
    xalaros is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2015
    Posts
    6
    I am not using a lookup fild and unfortunattely the file is too big to get posted. From what I am reading the issue seems to be about column widht and bound but I have tried everything and doesnt seem to work. I was hopping that I wsa missing something and someone could point me to the right direction

  7. #7
    JamesDeckert is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2015
    Location
    Salina, KS
    Posts
    262

  8. #8
    xalaros is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2015
    Posts
    6
    JamesDeckertthank you very much for the video. Its now clear to me how to manipulate the collumn properties of a combobox.

    But unfortunatelly my issue remains. let me show you in some pics a part of my issue.

    The field 1 search on the combobox 1


    If i search for the term "CLUB" that I know exist on the collumn returns nothing


    If i search for the term "8" that I know is the ID of Ermionis Club returns the following:
    Click image for larger version. 

Name:	3-1.JPG 
Views:	10 
Size:	100.7 KB 
ID:	23845



    The code that I am using to perform the search when the filter button is pressed is the following as given to the allan browne site http://allenbrowne.com/ser-62.html:

    Code:
    'Purpose:   This module illustrates how to create a search form, _            where the user can enter as many or few criteria as they wish, _
                and results are shown one per line.
    'Note:      Only records matching ALL of the criteria are returned.
    'Author:    Allen Browne (allen@allenbrowne.com), June 2006.
    Option Compare Database
    Option Explicit
    
    
    Private Sub cmdFilter_Click()
        'Purpose:   Build up the criteria string form the non-blank search boxes, and apply to the form's Filter.
        'Notes:     1. We tack " AND " on the end of each condition so you can easily add more search boxes; _
                            we remove the trailing " AND " at the end.
        '           2. The date range works like this: _
                            Both dates      = only dates between (both inclusive. _
                            Start date only = all dates from this one onwards; _
                            End date only   = all dates up to (and including this one).
        Dim strWhere As String                  'The criteria string.
        Dim lngLen As Long                      'Length of the criteria string to append to.
        Const conJetDate = "\#dd\/mm\/yyyy\#"   'The format expected for dates in a JET query string.
        
        '***********************************************************************
        'Look at each search box, and build up the criteria string from the non-blank ones.
        '***********************************************************************
        'Text field example. Use quotes around the value in the string.
           
        'Another text field example. Use Like to find anywhere in the field.
        If Not IsNull(Me.txt1) Then
            strWhere = strWhere & "([1] Like ""*" & Me.1 & "*"") AND "
        End If
    
    
        
        '***********************************************************************
        'Chop off the trailing " AND ", and use the string as the form's Filter.
        '***********************************************************************
        'See if the string has more than 5 characters (a trailng " AND ") to remove.
        lngLen = Len(strWhere) - 5
        If lngLen <= 0 Then     'Nah: there was nothing in the string.
            MsgBox "Δεν Υπάρχουν Κριτήρια Αναζήτησης", vbInformation, "Nothing to do."
        Else                    'Yep: there is something there, so remove the " AND " at the end.
            strWhere = Left$(strWhere, lngLen)
            'For debugging, remove the leading quote on the next line. Prints to Immediate Window (Ctrl+G).
            'Debug.Print strWhere
            
            'Finally, apply the string as the form's Filter.
            Me.Filter = strWhere
            Me.FilterOn = True
        End If
    End Sub
    
    
    Private Sub cmdReset_Click()
        'Purpose:   Clear all the search boxes in the Form Header, and show all records again.
        Dim ctl As Control
        
        'Clear all the controls in the Form Header section.
        For Each ctl In Me.Section(acHeader).Controls
            Select Case ctl.ControlType
            Case acTextBox, acComboBox
                ctl.Value = Null
            Case acCheckBox
                ctl.Value = False
            End Select
        Next
        
        'Remove the form's filter.
        Me.FilterOn = False
    End Sub
    
    
    Private Sub Form_BeforeInsert(Cancel As Integer)
        'To avoid problems if the filter returns no records, we did not set its AllowAdditions to No.
        'We prevent new records by cancelling the form's BeforeInsert event instead.
        'The problems are explained at http://allenbrowne.com/bug-06.html
        Cancel = True
        MsgBox "You cannot add new clients to the search form.", vbInformation, "Permission denied."
    End Sub
    
    
    Private Sub Form_Open(Cancel As Integer)
        'Remove the single quote from these lines if you want to initially show no records.
        'Me.Filter = "(False)"
        'Me.FilterOn = True
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query Search Form - Searching Between Two Dates
    By ryanmce92 in forum Queries
    Replies: 7
    Last Post: 06-05-2015, 01:46 PM
  2. Replies: 8
    Last Post: 06-09-2014, 01:23 PM
  3. Issue with searching and filtering query
    By federer8 in forum Queries
    Replies: 1
    Last Post: 02-08-2013, 06:21 PM
  4. Combo Box Data Entry Form Issue
    By MintChipMadness in forum Forms
    Replies: 24
    Last Post: 08-06-2012, 05:04 PM
  5. Replies: 6
    Last Post: 07-19-2012, 11:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums