Problems with deleting a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a filtering system in place to locate a specfic record in a table, but
for some odd reason it refuses to delete programically.

The code is as follows:

Criteria = "EmpID = " & EmpID & " and CourseID = " & CorID & " and SessionID
= " & SessID & " and CertificationDate = " & Cordate

With DoCmd
.SetWarnings False
.RunSQL "Delete * From EmpAwareness Where " & Criteria
.SetWarnings True
End With

This code is placed inside a sub in a module. What am I doing wrong?
 
Hi, Cameron.
What am I doing wrong?

The syntax you're using indicates that every variable contains a number, not
a string or date. CertificationDate is probably where the error is. Try
delimiting the date variable with pound signs:

.. . . & " and CertificationDate = #" & Cordate & "#"

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blog: http://DataDevilDog.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
When you use a criteria it should be different for text, number and date.
So, if the Cordate is a date field try:

Criteria = "EmpID = " & EmpID & " and CourseID = " & CorID & " and SessionID
= " & SessID & " and CertificationDate = #" & Cordate & "#"

A text field should have single quote
e.g, if SessID is a string type

Criteria = "EmpID = " & EmpID & " and CourseID = " & CorID & " and SessionID
= '" & SessID & "' and CertificationDate = #" & Cordate & "#"
 
I tried eliminating the date field all together and it still didn't delete
the record. All the fields with ID in them are index fields and SessionID is
unique so searching for it would turn up a unique list, all I could do then
is search for the EmpID to locate the record that would need to be deleted.
But when I tried that, it still didn't delete the record.

Am kind of baffled.
 
Back
Top