Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Like SQL query in Access error

Posted on 2011-03-23
14
Medium Priority
?
737 Views
Last Modified: 2012-06-21
Hello experts,

I'm having issues trying to run a like query in MS Access.  When I run the query it continues to give me an "Unknown" error.  The table that I'm querying from is a linked to an excel spreadsheet.  I'm running the query in Access through the query module.  Please help!  

SELECT Everyone.[First Name], Everyone.[Last Name], Everyone.[Entering Grade], Everyone.[Parent/Guardian Name], Everyone.[Tuition Options]
FROM Everyone
WHERE Everyone.[Tuition Options] Like '*Option A*'
0
Comment
Question by:Ruckafella
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
14 Comments
 
LVL 7

Expert Comment

by:TheTull
ID: 35199987
Have you tried replacing the * characters with %?  I know at least in T-SQL the syntax has you use %, so like this:

where everyone like '%option a%'
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35200546
That won't work in Access.  Just to make sure all spelling is correct, run the query without the WHERE clause.  If it returns records you are good to go.  Now replace the WHERE clause  with:

WHERE Everyone.[Tuition Options] Like "*Option A*";
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35200587
I run A2003, I just tested that Like clause and it works.  
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Ruckafella
ID: 35201036
GRayL,

I'm running Access 2007, and it still didnt work.  I erased the WHERE clause and the query returned all rows.  I added an equal WHERE clause and the query returned the  appropriate records.  Its just when I run the LIKE query that everything goes wrong.  I tried your query and it still gives me the "Unknown" error.
0
 

Author Comment

by:Ruckafella
ID: 35201065
More specifically, what happens is that it will return the correct records and display for about two seconds before the "Unknown" error pops up.  After the Unknown error comes, all the returned values display as "#Name?"
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35201315
then I suggest your db is 'busted'.

Try creating a new database, and import all the objects from the old one into the new one - use File, Get External Data, Import, and follow the Wizard.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35201326
Before that you should try a Compact & Repair in Tools
0
 

Author Comment

by:Ruckafella
ID: 35202120
Compact and Repair didnt do anything to help.  I dont think the database is "busted".  Every other query I run works fine, except the LIKE.  Do you think it may have something to do linked tables?  I would think I should be able to query a linked table.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35202200
Linked to what  - SQL Server?  If so, because the table is linked, SQL Server is providing the link with all the data and Jet should be able to apply the link criteria as if it were an Access table - I think!
0
 
LVL 7

Accepted Solution

by:
TheTull earned 2000 total points
ID: 35202379
If you try selecting just the top 5 records or so then, do they come back ok before it gets a chance to crap out on you?  This sounds like some bug where Access can't handle using the LIKE function when linking to Excel.
0
 

Assisted Solution

by:Ruckafella
Ruckafella earned 0 total points
ID: 35207167
TheTull,

It looks like you're on to something there.  When I do a Top 5 query with the exact same WHERE clause, it works fine.  Where do you think the problem is?
0
 

Author Comment

by:Ruckafella
ID: 35207323
Thanks for the hint to use the Top select query.  I was able to locate records that were in the excel spreadsheet that were causing problems.  The was data in excel that was too long for access to handle and this is where there error was coming from.
0
 
LVL 7

Expert Comment

by:TheTull
ID: 35208062
Ah, glad to see you got it working.  Sometimes those little checks can really help bring things to light.
0
 

Author Closing Comment

by:Ruckafella
ID: 35239057
Thanks, solution lead me in the correct direction to find the issue with the excel spreadsheet
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question