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

Delete query question - duplicate field?

Status
Not open for further replies.

baldmike

Programmer
May 30, 2012
2
US
I am a relative rookie to Access and VBA, but have inherited a database to manage.
I have been going through the VBA, tables and queries to get familiar and came across the delete query below. I am assuming that there is a reason for the inclusion of the column name in addition to the global (*) and am having trouble searching for information on it.
Unfortunately, the original developer is not around for me to ask.
Any information would be appreciated.

The short question is: Why include the specific reference to tblData.Value when already deleting tblData.*?

DELETE tblData.*, tblData.Value
FROM tblData
WHERE ((tblData.Value = 0) or (tblData.Value is Null));

Thanks much.
 

In my opinion you do not need it. You may as well say:
[tt]
DELETE FROM tblData
WHERE (Value = 0 or Value is Null);[/tt]

You are deleting the whole record.

BTW, Value is a terrible name for the Field, along with Name, Time, Date, and all other 'reserved' words.

Have fun.

---- Andy
 
Thanks Andrzejek -

I could see no functional difference when running the query both ways, but figured there was something to it since the OP went to the trouble to include it.

I genericized the table and column names since they are quite lengthy in the actual code. I will choose my pseudonyms with more care next time.
 

I understand.
Keep in mind: just because it is written this way, doesn’t necessarily mean it could not be written in other way. When I look at my programs and solutions from a few years ago I often go: “What was I thinking..?” :) Now I have a lot better ways to do stuff, and that’s probably (hopefully) the truth for other programmers.


Have fun.

---- Andy
 
What you have appears to be an SQL statement created using the Create- Design View (Query-By-Example or QBE) in Access instead of writing it in code. When you create a Delete query in QBE you select the * from the field list, but if you aren't deleteing all of the reocrds you must also select the field(s) the filter will be based on and then enter the criteria. Once you select the field(s) to enter the criteria Access automatically defaults to "Show" that field in the query. In an action query (append/delete)this results in a duplicate field error and you have to uncheck the "Show" checkbox in the designer window. If you look at your query in Design view the * and the field "Value" are selected and both have the "Show" checkbox checked. Uncheck the "Show" checkbox for the "Value" field and the error will not occur.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top