Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 January 28th, 2005, 03:41 PM
Authorized User
 
Join Date: Dec 2003
Location: Brussels, , Belgium.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Active Search Field

Hello All,
I a currently designing a search tool in Access 2003 VBA and I am stuck with the following:
I have a form with various fields coming from a Query. I made a new form and used the previous one as subform. A the top of the form, in the header, I have a text box in which the user will type in the search string and instead of clicking a "Search" button, I would like the search to happen while typing. I applied the event 'on change' on the search text field but apparently it does not work. Could you help me on that one?
Thank You,
Sven

 
Old January 30th, 2005, 01:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi Sven,

Try:

Private Sub txtSearch_Change()
    Dim strSQL As String

    strSQL = "SELECT * FROM tblCustomers "
    strSQL = strSQL & "WHERE [CompanyName] LIKE '" & txtSearch.Text & "*" & "'"

    With Me.fsubCustomers.Form
        .RecordSource = strSQL
        .Requery
    End With

End Sub

txtSearch is unbound. The code inserts a wildcard character into your search criteria, then resets the the subform's recordsource and requery's it.

HTH,

Bob





Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple field search ddnk77872 PHP Databases 0 May 15th, 2007 02:55 AM
all field search surendran MySQL 6 December 22nd, 2006 12:20 AM
How to Search in nTEXT or TEXT field gaupa SQL Server 2000 1 December 21st, 2004 07:48 AM
How do you search datetime field? SoC Classic ASP Basics 6 October 31st, 2004 09:39 PM
search for null /String.Empty in Active Directory georgeh C# 1 October 16th, 2003 08:09 AM





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