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 February 14th, 2006, 01:56 PM
Authorized User
 
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default ALike

This is so basic that I'm almost embarrassed to ask, but I b******d if I can find the answer.

I have a piece of SQL in a small module that sets the RecordSource of a form depending on a value entered in a text box

SELECT * FROM tbl_employees WHERE [Name] Like '*mc*' ORDER BY Eenum;

Simple, no problems. I use the Like operator as we need to do wildcard searches of employees. This has been running well for months, but suddenly yesterday it kept reporting no records found. I copied the SQL into a query and looked at it in design view, only to discover that the 'Like' operator was been changed to 'ALike'. I have been playing with Access for years, but have never seen or used this before. In other databases, the Like operator still performs as it ought, but even on other tables in the problem database, all queries that contain 'Like' will not run.

We have recently upgraded to Access 2003 from 2000. Is this causing it?

Help!



 
Old February 15th, 2006, 08:50 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This was the only info I could find on this undocumented issue:

"Using ADO wildcards in the query design grid
Making the necessary adjustments to change DAO wildcards to ADO wildcards may be a simple task, but if you're using ADO wildcards in your code you may prefer to also do so in the query design grid. Although it's undocumented, there is a way to use ADO wildcards in Access 2000's query design grid. Instead of using the Like operator, use ALike. For instance, you could use the criteria

ALike "_r_s__n%"


to replace our previous Kreskin example. The ALike operator works in SQL statements used in code as well, allowing you to easily take advantage of using the query design grid to create SQL statements."

From: http://msdn.microsoft.com/library/de...ml/ima0601.asp

HTH



mmcdonal
 
Old February 15th, 2006, 08:52 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Reading my own post it seems that if you get into this problem, use the SQL wild card character "%" instead of the Access SQL wild card "*".

HTH


mmcdonal









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