Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

correct syntax for setting up a SQL string for CurrentDb.Execute 1

Status
Not open for further replies.

irethedo

Technical User
Feb 8, 2005
429
0
0
US
I use the CurrentDb.Execute command quite often to launch a query within my DBA code but sometimes the
syntax doesn't exactly match the SQL of my query like in the following:

This works:
Code:
    strSql = "delete * from SameOrd_tbl where License_PartNo is null"

    CurrentDb.Execute strSql

This is totally wrong:
Code:
    strSql = "Delete * FROM SameOrd_tbl WHERE (((SameOrd_tbl.License_PartNo)=" "))"

    CurrentDb.Execute strSql

How do I fix the totally wrong?


Thanks
 
i dont know you want to delete
try
strSql = "Delete * FROM SameOrd_tbl WHERE (((SameOrd_tbl.License_PartNo)=''))"
or
strSql = "Delete * FROM SameOrd_tbl WHERE (((SameOrd_tbl.License_PartNo)=' '))"

do you know what the difference between
1)null
2)empty string
3)space
is?
 
If the field actually might contain a single space then try:

Code:
strSql = "Delete * FROM SameOrd_tbl WHERE License_PartNo=' '"

Or

Code:
strSql = "Delete * FROM SameOrd_tbl WHERE License_PartNo="" """

Duane
Hook'D on Access
MS Access MVP
 
How is the [tt]License_PartNo[/tt] field defined in the table? A text? A number? Is NULL allowed?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Thanks Duane-

Code:
strSql = "Delete * FROM SameOrd_tbl WHERE License_PartNo=' '"

This did the trick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top