Delete Query Criteria

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

Guest

I would like to delete unmatched records from a table. I have created an unmatched records query that identifies the records to be deleted. However, when I try to use the unmatched query as the criteria for deletion I get a message that says "Could not delete from specified tables".

The SQL for the query looks like this:

DELETE tblGuests.*, tblGuests.fldGuest, tblGuests.fldGolfDate
FROM tblGuests, [UnMatchedGuestsPlayers1-4Combined]
WHERE (((tblGuests.fldGuest)=[UnMatchedGuestsPlayers1-4Combined]![fldGuest]) AND ((tblGuests.fldGolfDate)=[UnMatchedGuestsPlayers1-4Combined]![fldGolfDate]));

Any help would be appreciated.
 
Try this (assumes that you want to delete records from tblGuest that are in
the UnMatchedGuestsPlayers1-4Combined table):

DELETE tblGuests.*
FROM tblGuests WHERE
tblGuests.fldGuest IN
(SELECT T.fldGuest FROM
[UnMatchedGuestsPlayers1-4Combined] AS T
WHERE T.fldGuest = tblGuest.fldGuest AND
T.fldGolfDate = tblGuests.fldGolfDate);

--

Ken Snell
<MS ACCESS MVP>




Bob Mullen said:
I would like to delete unmatched records from a table. I have created an
unmatched records query that identifies the records to be deleted. However,
when I try to use the unmatched query as the criteria for deletion I get a
message that says "Could not delete from specified tables".
The SQL for the query looks like this:

DELETE tblGuests.*, tblGuests.fldGuest, tblGuests.fldGolfDate
FROM tblGuests, [UnMatchedGuestsPlayers1-4Combined]
WHERE
(((tblGuests.fldGuest)=[UnMatchedGuestsPlayers1-4Combined]![fldGuest]) AND
((tblGuests.fldGolfDate)=[UnMatchedGuestsPlayers1-4Combined]![fldGolfDate]))
;
 
Ken:

It worked perfectly, thanks very much for you time and expertise.
--
Bob Mullen


Ken Snell said:
Try this (assumes that you want to delete records from tblGuest that are in
the UnMatchedGuestsPlayers1-4Combined table):

DELETE tblGuests.*
FROM tblGuests WHERE
tblGuests.fldGuest IN
(SELECT T.fldGuest FROM
[UnMatchedGuestsPlayers1-4Combined] AS T
WHERE T.fldGuest = tblGuest.fldGuest AND
T.fldGolfDate = tblGuests.fldGolfDate);

--

Ken Snell
<MS ACCESS MVP>




Bob Mullen said:
I would like to delete unmatched records from a table. I have created an
unmatched records query that identifies the records to be deleted. However,
when I try to use the unmatched query as the criteria for deletion I get a
message that says "Could not delete from specified tables".
The SQL for the query looks like this:

DELETE tblGuests.*, tblGuests.fldGuest, tblGuests.fldGolfDate
FROM tblGuests, [UnMatchedGuestsPlayers1-4Combined]
WHERE
(((tblGuests.fldGuest)=[UnMatchedGuestsPlayers1-4Combined]![fldGuest]) AND
((tblGuests.fldGolfDate)=[UnMatchedGuestsPlayers1-4Combined]![fldGolfDate]))
;
 
You're welcome.

--

Ken Snell
<MS ACCESS MVP>

Bob Mullen said:
Ken:

It worked perfectly, thanks very much for you time and expertise.
--
Bob Mullen


Ken Snell said:
Try this (assumes that you want to delete records from tblGuest that are in
the UnMatchedGuestsPlayers1-4Combined table):

DELETE tblGuests.*
FROM tblGuests WHERE
tblGuests.fldGuest IN
(SELECT T.fldGuest FROM
[UnMatchedGuestsPlayers1-4Combined] AS T
WHERE T.fldGuest = tblGuest.fldGuest AND
T.fldGolfDate = tblGuests.fldGolfDate);

--

Ken Snell
<MS ACCESS MVP>




Bob Mullen said:
I would like to delete unmatched records from a table. I have created
an
unmatched records query that identifies the records to be deleted. However,
when I try to use the unmatched query as the criteria for deletion I get a
message that says "Could not delete from specified tables".
The SQL for the query looks like this:

DELETE tblGuests.*, tblGuests.fldGuest, tblGuests.fldGolfDate
FROM tblGuests, [UnMatchedGuestsPlayers1-4Combined]
WHERE
(((tblGuests.fldGuest)=[UnMatchedGuestsPlayers1-4Combined]![fldGuest]) AND
((tblGuests.fldGolfDate)=[UnMatchedGuestsPlayers1-4Combined]![fldGolfDate]))
;
Any help would be appreciated.
 
Back
Top