Results 1 to 3 of 3
  1. #1
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104

    Query that would search multiple critera and delete

    I'm looking to structure a query that would match ALL of the following critera:



    SITE
    PAMOUNT
    DateAdded
    Initial

    Then delete it; these are going to be text boxes on a form with a button to search in case of accidental/erraneous entry.

    I would use a unique ID to do it, but I've already implemented it and I'd like to just have something that will specifically match multiple critera (see above) and delete that entry.

    The only other issue I see is that the DateAdded might be structured 8/11/2010 or like 12/11/2010, depending on if the month is two-digit or not.

    Any help is much appreciated .


    Justin

  2. #2
    jzwp11 is offline VIP
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I believe that as long as the dateAdded field is set to a date/time datatype (not text), you should not have a problem with the one or two digit months or days. Your delete query would look something like this (you will have to substitute your own form & form control names as well as adjust the table and field names to be consistent with your database).

    DELETE myTableName.*
    FROM myTableName
    WHERE (((myTableName.SITE)=forms!myFormName!mySiteContro lName) And ((myTableName.PAMOUNT)=forms!myFormName!myAmountCo ntrolName) And ((myTableName.DateAdded)=forms!myFormName!myDateAd dedControlName) And ((myTableName.Initial)=forms!myFormName!myInitialC ontrolName));

  3. #3
    justinwright is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    104
    Just to update everyone, the code I used for the button (in case this can help someone else in the future), is as follows:

    Code:
        CurrentDb.Execute "Delete * from List WHERE FIELDONE = " & Me.txtText1 & " AND FIELDTWO = " & Me.txtText2 & " "
    This takes the txtText1 and txtText2 boxes and goes through the table called "List" and removes them if each both match for FIELDONE and FIELDTWO for their respective boxes.

    Thanks for the help!!!!

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

Similar Threads

  1. Search for multiple records
    By Blake in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 03:17 AM
  2. Delete multiple selections
    By Evgeny in forum Programming
    Replies: 7
    Last Post: 07-20-2010, 01:14 PM
  3. Replies: 0
    Last Post: 04-08-2010, 12:22 PM
  4. How can I search multiple tables?
    By botts121 in forum Access
    Replies: 4
    Last Post: 02-02-2010, 06:39 AM
  5. Replies: 1
    Last Post: 02-25-2009, 07:29 PM

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