VBA Delete Record in Table Not working

djossh

Registered User.
Local time
Today, 19:04
Joined
Oct 19, 2011
Messages
89
Hi I tried to delete a record (Project) in a table(TimesheetTbl) with Null or blank value.. I tried this code but I don't know why it's not working.. Here's the code..

CurrentDb.Execute "DELETE * FROM TimesheetTbl WHERE Project = IsNull(Project)"
 
IsNull() returns True or False, but
Code:
Project Is Null
will help you collect Project fields that have null values.. So try this..
Code:
CurrentDb.Execute "DELETE * FROM TimesheetTbl WHERE Project Is Null"
 
IsNull() returns True or False, but
Code:
Project Is Null
will help you collect Project fields that have null values.. So try this..
Code:
CurrentDb.Execute "DELETE * FROM TimesheetTbl WHERE Project Is Null"


Thanks for the reply.. but it's not working.. here's my complete code .. Im a newbie to VBA and just copied some of my code over internet.

Dim db As Database

Set db = CurrentDb()

CurrentDb.Execute "DELETE * FROM TimesheetTbl WHERE Project IsNull"

Set db = Nothing
End Sub

Im getting this error message "syntax error (missing operator) in query expression Project IsNull"
 
Last edited:
It is not 'IsNull' as one word.. it is Is<space>Null (two separate words)..
 
You are welcome...

Just a word of advice, before performing Deletion or Update, always try to SELECT the data first, this way you can be rest assured that the data set you have in the select Query is what you intend to delete/update.. If the result set is correct replace the word SELECT with UPDATE/UPDATE.. As these two action queries cannot be easily undone.. Hope this makes sense..

Have a good day.. And good luck.. :)
 

Users who are viewing this thread

Back
Top Bottom