Results 1 to 9 of 9
  1. #1
    Buns1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    16

    Need help with a delete query

    Hi Everyone,



    I am in need of some help on a delete query in an Access table.

    I have a linked Excel table which is a worksheet that is filled out daily. That worksheet has several columns that are
    deleted daily with a macro so we can enter new data. What remains are various formulas in various columns. We have
    row2:row71. Not all rows are populated daily but they still show some columns which are waiting on population.

    Once the Excel form is complete, it is saved and then we append to a table in Access. The issue is that the rows we didn't
    populate in Excel still have enough data in them from the formulas in Excel to create a record in the Access table creating clutter and useless information.

    With that said what I would like to do is create a Delete Query that would delete any records with a NULL value in a given field
    so for example if Field "NEWDATA" is null or empty then delete that record.

    Thank you!

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,840
    query criteria - WHERE IS NULL [NEWDATA] Suggest you try this on a copy of your table first.
    Your append to the database table should prevent this in the first place.
    Last edited by Micron; 02-26-2019 at 10:24 AM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Buns1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    16
    I would actually prefer that the Append Query "prevent this in the first place" so I must be doing something wrong there? I think the issue is that in Excel column A3:A71 we have
    a date that is copied down from Cell A2 because we are never sure how many rows we will need. One day it may be 70, the next it may be 50, and the next 60 depending on whether
    or not we received inventory.

    Quote Originally Posted by Micron View Post
    query criteria - WHERE IS NULL [NEWDATA] Suggest you try this on a copy of your table first.
    Your append to the database table should prevent this in the first place.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,840
    2 approaches
    - use a different column to provide the actual range of data rows ; one that isn't full of unimportant values
    - use dynamic named range in Excel. The range is as large as the rows/columns that contain values. But put range at sheet level, not workbook. Much more adaptive but more difficult to get into Access. Automation is one way. Transferspreadsheet function is another but I can't recall from which application (excel or access) in order to be able to use a range in that method.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Buns1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    16
    Micron
    I am getting an error "You have entered an Operand without an Operator". Sorry very new to Access.

    Thank you

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,840
    As oft said, post what you tried. "Doesn't work" doesn't help. If I was a mind reader I wouldn't get into so much trouble with the wife!

  7. #7
    Buns1976 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    16
    Micron,

    As indicated in my most recent post "You have entered an Operand without an Operator" and I'm not sure where to go with that?
    Obviously missing something in the equation literally! As previously mentioned I am very new to Access and its pretty much all
    Greek to me. No offense intended!

    Code:
     WHERE IS NULL [NEWDATA] 

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    Go to your query; design view; SQL view
    Copy all of the SQL
    Paste that SQL in your post.

    We need some context for the post.

  9. #9
    Join Date
    Apr 2017
    Posts
    1,689
    Foolproofest way I use to get a query from Excel:

    Define fixed (not dynamic) range with lot of rows (20 000 or 50 000 or whatever);
    Base the query on this fixed range, with clause "WHERE SomeField Is Not Null";
    Add additional conditions when they are needed.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Delete query to delete records that meet criteria
    By neill_long in forum Queries
    Replies: 1
    Last Post: 06-11-2018, 02:41 PM
  2. Replies: 7
    Last Post: 09-16-2017, 04:01 PM
  3. Delete Button vs. Delete Query
    By JennyL in forum Access
    Replies: 4
    Last Post: 02-11-2017, 10:11 PM
  4. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  5. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums