Results 1 to 3 of 3
  1. #1
    Darla is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    May 2016
    Posts
    25

    Deleting A Record Based On A Value In A Text Box?

    Hi everyone! I was hoping someone could help me with this. I have a form that's tied to a table. What I'm trying to do it to have a button that looks at the value of TextBoxA on the current form, and then finds that record in FieldA in the table then deletes it. I'm terrible at explaining things, so for example, I have my form up, and in TextBoxA I have a value of "7117". I want to delete the record in my table that equals "7117" in FieldA by clicking the button.




    What is the best way to do this?

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    DoCmd.SetWarnings False
    DoCmd.RunSQL = "DELETE FROM YourTable WHERE YourFieldInYourTable = '" & Me.TextBoxA & "'"

    Just have a good backup of your data and test it well.

  3. #3
    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,849
    Darla,

    Delete queries can be very unforgiving.
    Be very careful with your development and testing to ensure you have
    a-- a backup of your database and/or table
    b--tested your code as a Select query to ensure you get the correct record(s), once satisfied, change to DELETE query

    Many systems do not physically delete records, they mark them with a flag eg: IsDeletedYN and use logic to treat records with IsDeleted = Y
    as logically deleted.

    Good luck.

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

Similar Threads

  1. Replies: 6
    Last Post: 07-31-2016, 11:49 AM
  2. Find record based on text box
    By tazzzz in forum Forms
    Replies: 20
    Last Post: 12-21-2015, 01:59 PM
  3. Deleting text from each end of a line of text
    By mchadwick in forum Queries
    Replies: 6
    Last Post: 10-20-2015, 02:09 PM
  4. Replies: 2
    Last Post: 09-24-2014, 05:19 PM
  5. Replies: 2
    Last Post: 05-30-2012, 09:09 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