Solved

sql ('LIKE')statement

Posted on 2002-04-08
9
134 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 49

Expert Comment

by:Ryan Chong
ID: 6927095
Hi iven,

Try this instead:

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

Cheers
0
 
LVL 49

Expert Comment

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

DELETE FROM Employee
WHERE BN Like "ABC%"
0
 
LVL 5

Expert Comment

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

kcm

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 69

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 49

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now