Solved

sql ('LIKE')statement

Posted on 2002-04-08
9
138 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
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 51

Expert Comment

by:Ryan Chong
ID: 6927095
Hi iven,

Try this instead:

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

Cheers
0
 
LVL 51

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 51

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

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!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

749 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