Solved

sql ('LIKE')statement

Posted on 2002-04-08
9
139 Views
Last Modified: 2010-05-02
Hi,this is my problem.i want to delete the whole record that the BN start with ABC,when i test this sql in MS Access it works:

DELETE FROM Employee
WHERE BN Like "ABC*"

example:    BN
          ABC123
          ABC456

but error appear when i run it on VB.i try many way to replace the string of "ABC*" but failed.

sql = " SELECT * FROM Employee " & _
       "WHERE BN LIKE '" & ABC* & "' " <<syntax error

sql = " SELECT * FROM Employee " & _
       "WHERE BN LIKE '" & ABC% & "' " <<nothing selected

thanks!
0
Comment
Question by:iven
[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
9 Comments
 
LVL 5

Expert Comment

by:kcm76
ID: 6927093
ur first sql should work. any way try replacing double quotes with single as follows.

Delete * from Employee where bn like 'ABC*'


KCM
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 6927095
Hi iven,

Try this instead:

sql = " SELECT * FROM Employee " & _
      "WHERE BN LIKE '" & ABC & "%' "

Cheers
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 6927096
so, that's:

DELETE FROM Employee
WHERE BN Like "ABC%"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:kcm76
ID: 6927103
to: ryancys
It is not working in my sys.
mins is MS-Access2k.

kcm

0
 
LVL 5

Accepted Solution

by:
KarcOrigin earned 50 total points
ID: 6927106
Hi iven,
Try this -

Select * From Employee
Where BN Like " & "'ABC%'"
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6927109
looks list quotes problem:

sql = " SELECT * FROM Employee " & _
      "WHERE BN LIKE 'ABC%' " 
0
 
LVL 5

Expert Comment

by:kcm76
ID: 6927111
Iven u there.?
0
 
LVL 52

Expert Comment

by:Ryan Chong
ID: 6927118
kcm76, Use "%" in VB, use "*" when debuging in M$ Access..
0
 

Author Comment

by:iven
ID: 6927144
THANKS!!!!!u r so great!

also thanks every one that answer the question to me.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 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