Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I posted a query a short while ago and had an informed answer within a couple of hours. Terrific!..."

Geography

Where in the world do Tek-Tips members come from?
baldmike (Programmer)
30 May 12 14:33
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.
Andrzejek (Programmer)
30 May 12 14:43

In my opinion you do not need it. You may as well say:

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


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

baldmike (Programmer)
30 May 12 14:48
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.
Andrzejek (Programmer)
30 May 12 16:07

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..?” smile Now I have a lot better ways to do stuff, and that’s probably (hopefully) the truth for other programmers.

Have fun.

---- Andy

PaulF (TechnicalUser)
31 May 12 7:44
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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close