Solved

sql ('LIKE')statement

Posted on 2002-04-08
9
137 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

829 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