Results 1 to 3 of 3
  1. #1
    SltPhx is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41

    Question Deleting a specific record from a table using a value from a form

    Hello All,
    Please help me.

    I have a form where a user enter an ID and some details. This is saved in Table A.


    The ID is also in Table B - What I want is, once the user saves it in Table A-I want it to be deleted from Table B. Ultimately, Table A has all information and Table B will only have those IDs that haven't been entered in Table A.
    Basically what is entered in Table A shouldn't be there in Table B.

    Is there a way to do this using a macro?
    I did find a VBA code online - what is wrong here? I am not very familiar with VBA . This code also suppreses the warnings.

    Private Sub Submit_Enter()

    DoCmd.RunSQL "DELETE * FROM TBL_ClaimsToBeAssigned"
    where [Claim ID] = Forms![FRM_PendsAssign]![Claim ID]
    DoCmd.SetWarnings False
    DoCmd.RunSQL "DELETE * FROM TBL_ClaimsToBeAssigned"
    DoCmd.SetWarnings True

    End Sub


    Kindly help me. Thank you for your time and help.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    CurrentDb.Execute "DELETE FROM TBL_ClaimsToBeAssigned WHERE [Claim ID]=" & Me.[Claim ID]

    That method does not require the SetWarnings lines.

    To use a macro, would have to create and save Access DELETE query object. Then macro can run the query object.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    SltPhx is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41
    That worked!!!!! AWESOME!

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

Similar Threads

  1. Replies: 12
    Last Post: 12-04-2013, 06:19 PM
  2. Replies: 6
    Last Post: 11-15-2012, 05:38 PM
  3. Deleting The Sub-Form Record From Main Form
    By vdanelia in forum Forms
    Replies: 0
    Last Post: 11-08-2011, 04:33 PM
  4. Replies: 3
    Last Post: 03-23-2011, 11:37 AM
  5. Replies: 11
    Last Post: 12-14-2010, 01:25 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