Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 30th, 2007, 07:43 PM
Authorized User
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filter Records in a continuous form

Hi All,

If i could get some help with this please.
I have a continuous form listing product descriptions, on the header of my form i have placed an unbound textbox call txtsearch.
i wish to be able to enter a search string in the txtsearch and filter my records in the Continuous form accordingly.
Now the prod description contains info such as style, colour, name etc, when the user searches they may want to enter in the txtsearch info such as "red sofa baltimore" so i want the filter return to include all/any of the search criteria.
Eg that search should return "Red Chair" - "Blue Sofa" - "Baltimore Red Sofa Chair" in the continuous form.
I can get it filtering useing the like command but for some reason it will only return an exact match?
Can this be done?
Any help would be great


Old May 31st, 2007, 06:31 AM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

There is a reason it is only working with an exact match. If you look at the text string, you will see this:

SELECT * FROM MyTable WHERE [FieldValue] Like '*red sofa baltimore*'

Which means, give me every record where the phrase "red sofa baltimore" is anywhere in the FieldValue field.

This is a problem with design, first of all, that you would have all this information in the product description field, so you are going to have to split the string into an array and then rebuild the criteria from the array.

Dim MyArray As Variant
Dim i As Integer
Dim sString As String

sString = Me.txtUnboundTextBox

i = 0
MyArray = Split(sString, " ") 'That is a space bar between the double quotes

sString = "[ProductDescription] Like '*" 'reset

Do Until i = Ubound(MyArray) + 1
sString = sString & MyArray(i) & "*' Or [ProductDescription] Like '*"
i = i + 1

'Remove Excess - removes Or [ProductDescription] Like '* from the end of the string
sString = Left(sString, Len(sString - 32))

Then pass sString to your query. You may have to play with is a bit, but you get the idea.

Old June 1st, 2007, 06:50 AM
Authorized User
Join Date: Mar 2007
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts

Thank You

As usual your suggestion has taught me a bit more!

You are now at the top of my xmas card list!!!


Similar Threads
Thread Thread Starter Forum Replies Last Post
colour continuous form palmer Access 4 July 29th, 2009 03:26 AM
Continuous Form - Images nilkanth Access 9 July 29th, 2009 02:30 AM
Loop through records on Continuous Form paulcbyrum Access 1 May 13th, 2008 06:28 AM
ADP - continuous form color select records metta4u Access VBA 1 March 13th, 2008 06:42 AM
Highlight and Color records in a continuous form MichaelCree Access VBA 8 March 28th, 2005 05:32 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.