Wrox Programmer Forums
|
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 October 4th, 2004, 10:51 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filtering a form

Hi

I have a form that displays the relevant info about the Customers, it is based on a query (QryCustomers).

I want my users to be able to filter the form based on characters typed into a Textbox for instance:

if the user types: "Carl" in the Textbox I would like to filter all the records with "Carl" anywhere in the Customer_Name field to be displayed

When I use the formula:

Like "*[Carl]*"

in the Criteria column of the query it returns the required records, but when I try to reproduce this in a VBA module. i.e.

Dim Strfilter as string

Strfilter = "[Customer_Name] Like *[Me.searchName]*"
Me.filter "Strfilter"

I have tried various alternatives using the Ampersand & and the Sigle quote ' , but each time I seem to get an error(usaully a syntax error)

can anyone help?
thanks


ps I have also tried to create a Recordset but I run into the same problem the compiler doesn't seem to want to recognise the wildcard * character. In any case i'm still trying to figure out how to asign the new recordset to an opoen form?




 
Old October 5th, 2004, 03:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

When you use an asterisk sign enclose it with quotation mark like this:


LIKE "*" & "Carl" & "*"

OR

Strfilter = "Customer_Name = " & "*" & """ &[Me.searchName]& """" & "*"

Hope this helps.
John











Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use OR during filtering..... raaj81 Reporting Services 0 July 30th, 2008 05:34 AM
Filtering a DataGridView furjaw VB.NET 0 November 6th, 2007 02:03 AM
Problem Filtering Morteza_M Pro VB Databases 2 January 23rd, 2007 08:12 AM
Count() and filtering asearle XSLT 1 December 4th, 2006 06:19 AM
Filtering a Database fbobak Access 1 August 26th, 2004 12:21 AM





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