Results 1 to 5 of 5
  1. #1
    JennyL is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    51

    Delete Button vs. Delete Query

    Hi,



    I am trying to decide if I should use a delete button or delete query to delete a record. I only want the users who knows the delete password to delete the record. there are many tables linked to the "account table" and I want to limit the users who can delete. There will be times that users will probably create the wrong account due to typo, and needs it to be removed from the database. in those cases, they will need to notify the manager and then manager will go in to delete the record.

    should I create the delete button with password vba code next to the sub-form records? or should build a separate form using delete query where manager will have to enter the account number and then hit delete? the separate form of course will be under the Admin navigation page, so only users with admin rights will have ability to see this delete form.

    Any feedback is greatly appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    use a delete button,
    the code behind the button can ask for the password, user enters it, do a dlookup to confirm, then run the delete query.

    Code:
    sub btnDelete_click()
    
    ret = InputBox ("enter password","Delete record")
    vValid = Dlookup("[pass]","tPasswords","[pass]='" & ret & "'")
    if IsNull(vValid) then
       msgbox "Incorrect password"
    else
       docmd.openquery "qdDel1Record"
    endif
    
    end sub

  3. #3
    JennyL is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2017
    Posts
    51
    Quote Originally Posted by ranman256 View Post
    use a delete button,
    the code behind the button can ask for the password, user enters it, do a dlookup to confirm, then run the delete query.

    Code:
    sub btnDelete_click()
    
    ret = InputBox ("enter password","Delete record")
    vValid = Dlookup("[pass]","tPasswords","[pass]='" & ret & "'")
    if IsNull(vValid) then
       msgbox "Incorrect password"
    else
       docmd.openquery "qdDel1Record"
    endif
    
    end sub
    What does qdDel1Record mean? so I should create a delete query with criteria "Enter Account Number"? Otherwise, how would database know which record to delete?

    Thanks!

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a special form for deleting a record. The user enters the password to open the form (a check in VBA). On the delete form, the manager will select the record using a combobox and all the data will be displayed. A button can be called "Confirm deletion", when clicked you can run a query to delete that record, something like :
    DoCmd.RunSQL " DELETE * FROM tablename WHERE IDname =" & Me!SelectedID & ";"

  5. #5
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Use a delete button to run a delete query.

    I second aytee11's idea for the form. I like it. I would also have the delete form check to be sure that the user does not have the data entry for open also just to be safe.

    For functions like this I like to use an separate "Admin" front end linked to the same back end. I find it much easier to secure an entire front end.
    Last edited by HiTechCoach; 02-12-2017 at 10:00 AM.

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

Similar Threads

  1. Replies: 4
    Last Post: 12-13-2016, 09:48 AM
  2. Replies: 13
    Last Post: 05-06-2014, 12:42 PM
  3. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  4. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM
  5. Delete query button?
    By jpalk in forum Queries
    Replies: 2
    Last Post: 10-14-2010, 09:12 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