Solved

Access Vb - Filtering a List Control as Data is input in a Control Textbox - Grouping/Ordering List

Posted on 2013-01-06
3
306 Views
Last Modified: 2013-01-06
Hello All

This is a followup question to Original Question on same topic

Irog assisted in fixing the problem after Mbiz had pointed me down the correct path but I was missing a piece still.

The filtering of the list as the user inputs info into a bound textbox control works but the list is sorting based on the ID number.  I need to modify the code to keep the list filtered by the StreetName (text).....

The original code that filters (unsorted) is.....

    If Len(StreetName.Text) > 0 Then
        strSQL = "SELECT AddressStreetID, StreetName FROM dta_Streets" & _
        " WHERE AddressStreetID > 2 AND StreetName LIKE '" & Me.StreetName.Text & "*'"
    Else
        strSQL = "SELECT AddressStreetID, StreetName FROM dta_Streets"
    End If

    Me.listExistingStreets.RowSource = strSQL

Open in new window


Now then I attempted to modify the strSQL to Group and Order the list but it makes the filtering of the list unresponsive....

The code I tried changing it to is:
    If Len(StreetName.Text) > 0 Then
        strSQL = "SELECT AddressStreetID, StreetName FROM dta_Streets" & _
        " WHERE AddressStreetID > 2 AND StreetName LIKE " & Me.StreetName & "*'" & _
        " GROUP BY AddressStreetID, StreetName" & _
        " ORDER BY StreetName"
    Else
        strSQL = "SELECT AddressStreetID, StreetName FROM dta_Streets" & _
        " GROUP BY AddressStreetID, StreetName" & _
        " ORDER BY StreetName"

    End If
    
    Me.listExistingStreets.RowSource = strSQL

Open in new window


Is my syntax wrong on adding the Group By and Order By ????
0
Comment
Question by:wlwebb
  • 2
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 38748180
" I need to modify the code to keep the list filtered by the StreetName (text)...."

Do you mean Sorted by streetname.  If so remove both Group By clauses (lines 4 and 8)
0
 

Author Comment

by:wlwebb
ID: 38748184
When I do that the filtering of the list doesn't work......  oops I did mean sorted by StreetName, you are correct.

PS Yes, StreetName is Text
0
 

Author Closing Comment

by:wlwebb
ID: 38748186
Never mind... missed an ' in my code........  uggghhh
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

837 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