Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 4th, 2004, 10:51 AM
Registered User
Join Date: Aug 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filtering a form


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?

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?

Reply With Quote
  #2 (permalink)  
Old October 5th, 2004, 03:47 PM
Friend of Wrox
Join Date: Jul 2003
Location: South San Francisco, CA, USA.
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post

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

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


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

Hope this helps.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 10:22 PM.

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