Results 1 to 14 of 14
  1. #1
    yaviens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    8

    Post Delete row button

    Hi, I'm creating a database for people who know anything about access. For this reason I'm developing everything so that they work with forms and buttons. I need to add a delete button that can erase a row (not a single column). This delete button as I said is going to be in a form, but has to erase a row of a table.



    The problem is, I don’t know how to select a row with all his columns and delete the information inside.

    Thanks in advance.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Access provides a wizard to create a button that will delete the current record of a form. However, you may be better to add a field to the underlying record source which only gets populated once the user has confirmed that the record is to be deleted. The forms record source can have criteria set so that only records where this field are Null are returned which gives the illusion of the record being deleted but it is still there if it is ever needed.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    yaviens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    8
    Thank you for your help .

    If you mean the delete button that you can create up in the ribbon, it doesn't work.

    The first column of my rows has a primary key, if i try to erase this value it shows this error "Index or primary key cannot contain Null value". But if I go to the table I need and click right mouse on the row I want to erase it works and it erases the row.

    But as I said I need to do this action with a button from a form.

  4. #4
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Why do you want to delete a record? I have always found this a minefield. I prefer to have Yes/No field to hide the record. In my tables I have this at optMarkForDeletion. People check this, and then you filter anything out that has been ticked. This allows you to recover records "deleted" by accident. Also stops people from deleting records they shouldn't.

    Would appear to the common user that they have deleted the record, but a power user would be able to see any records marked for deletion.

    ~Matt

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by Subwind View Post
    Why do you want to delete a record? I have always found this a minefield. I prefer to have Yes/No field to hide the record. In my tables I have this at optMarkForDeletion. People check this, and then you filter anything out that has been ticked. This allows you to recover records "deleted" by accident. Also stops people from deleting records they shouldn't.

    Would appear to the common user that they have deleted the record, but a power user would be able to see any records marked for deletion.

    ~Matt
    I agree. That's the kind of approach I was suggesting in my last post.

    yaviens
    I use A2003 so the ribbon is an enigma to me. However, see: https://www.youtube.com/watch?v=ClPHO1-L54g for a video of using the wizzard to create a button.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    yaviens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    8
    Sorry I'm a bit new with Access but I don't understand what is optMarkForDeletion. And how do I do that my already created tables have a Yes/No row?

    And thanks for all the help

  7. #7
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    I question this approach. If you wanna look at the table and select a row ascending or descending then the "deleted" records are amongst them.

    My approach is to have a seperate table to dump the deleted records in with a SQL insert statement.
    On my form there is a radiobutton called "history" and once clicked the forms recordsource is changed to the table with the deleted records.

  8. #8
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    I question this approach. If you wanna look at the table and select a row ascending or descending then the "deleted" records are amongst them.
    But users should not be looking at tables. They will be viewing the data on a form or report which uses a query that excludes the "deleted" records.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  9. #9
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Well my users can look at tables but they cannot edit anything there because its Read-only..
    I frequently add fields to the table, it would be a pain in the behind for me to keep on adding these fields to the queries and reports. But ive never heard of the one-table approach so it gets me thinking.

    Just wanted to point out there is another way

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by JeroenMioch View Post
    Well my users can look at tables but they cannot edit anything there because its Read-only..
    I frequently add fields to the table, it would be a pain in the behind for me to keep on adding these fields to the queries and reports. But ive never heard of the one-table approach so it gets me thinking.

    Just wanted to point out there is another way
    Why would you need to add fields to a table frequently and what is it that gets you thinking.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    Well my db is a facility office management system and has many fields allready, but i find myself adding new functions to it frequently and thus new fields.

    What has got me thinking is that there are other approaches as to my two-tables method

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    What has got me thinking is that there are other approaches as to my two-tables method
    Often more than one way to achieve a goal in Access. That's why we're here.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  13. #13
    yaviens is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    8
    But how I create a button that delete rows?

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by yaviens View Post
    But how I create a button that delete rows?
    In post#5 I wrote: yaviens
    I use A2003 so the ribbon is an enigma to me. However, see: https://www.youtube.com/watch?v=ClPHO1-L54g for a video of using the wizzard to create a button.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. delete button to somewhere else
    By azhar2006 in forum Forms
    Replies: 5
    Last Post: 03-22-2014, 03:29 PM
  2. delete button
    By azhar2006 in forum Forms
    Replies: 2
    Last Post: 02-22-2014, 01:49 PM
  3. delete button
    By msasan1367 in forum Access
    Replies: 2
    Last Post: 05-31-2013, 10:25 PM
  4. Delete query button?
    By jpalk in forum Queries
    Replies: 2
    Last Post: 10-14-2010, 09:12 AM
  5. Add/Delete Button
    By ocemy in forum Forms
    Replies: 1
    Last Post: 03-29-2009, 08:08 PM

Tags for this Thread

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