Delete not working

B

Bandit

Hi,
Can anyone see why this code isn't working? It is
similiar to the code that I use to add a record without
any problem. Thanks,,,

'-- Grab the first column
strQuestion = Me!lstReturnedQuestions.Column
(0, varQuestionsReturned)
'-- Set the other variables
strJob = Forms![CI-MI Questions]![cboJobs]
strArea = Forms![CI-MI Questions]![cboArea]
strCategory = Forms![CI-MI Questions]!
[cboCategory]

sql = "Delete from qryBOM_CIMI where
(JobNumber = '" & strJob & "' AND QuestionID = '" &
strQuestion & "' AND Area = '" & strArea & "' AND Category
= '" & strCategory & "');"

DoCmd.RunSQL sql
 
W

Wayne Morgan

Have you opened the query qryBOM_CIMI and verified that a record exists in
the query that matches the criteria? You are using single quotes around the
criteria. Do any of the criteria strings have apostrophes in them? Do you
have a table relationship enforcing referential integrity that won't let you
delete a record that has related data in another table?

Do you get any error messages or does it just not delete the record? Have
you tried creating the query in the query design grid and trying it from
there?
 
W

Wayne Morgan

Another possibility, if you open qryBOM_CIMI, can you manually delete a
record from the query by using the delete button on the toolbar?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top