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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!!: Delete query does not work

Status
Not open for further replies.

whatisahandle

Programmer
Jul 26, 2001
18
CA
Hi Folks,

I have this Query Definition:

PARAMETERS [nom_gabarit] Text ( 255 ), [NoCompagnie] number;

DELETE *
FROM cat_gabarit
WHERE nom_gabarit = [nom_gabarit] and NoCompagnie = [NoCompagnie];

The query deletes all records in the table, even when I run it in design mode.
The table is in SQL2000 linked to access with ODBC.

In the code I run it this way (both parameters really contain values):

Set deleteCatGabarit = CurrentDb.QueryDefs("delete_Cat_gabarit")
deleteCatGabarit.Parameters![nom_gabarit] = sTemplateName
deleteCatGabarit.Parameters![NoCompagnie] = NoCompagnie
deleteCatGabarit.Execute (dbSeeChanges)

Set deleteCatGabarit = Nothing


Any ideas ?

Chris
 
I found the answer.

Here is why it does not work:

1- Access is expecting a primary key id in order to delete a specific record.

2- If the parameters have the same names as the table fields Access gets confuses them, and the query returns all the rows (every field beeing equal to itself ...)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top