How do I assign a delete query onto a command button?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jennytranxxx
    New Member
    • May 2012
    • 8

    How do I assign a delete query onto a command button?

    How do I assign a delete query onto a command button?

    I have read a few forums and it has told me to:
    1. Go to Properties
    2. Rename the Name and Caption, so i've renamed it to Runquery
    3. Under Event - On click I have also changed it to [Event Procedure] and paste:
      Code:
      Private Sub deletedatafromjob_Click()
      DoCmd.OpenQuery "deletedatafromjob"
      MsgBox "Code run"
      End Sub
    4. Then in the Build Event option, I have put in:
      Code:
      Private Sub deletedatafromjob_Click()
      DoCmd.OpenQuery "deletedatafromjob"
      MsgBox "Code run"
      End Sub

    My Delete query name is deletedatafromj ob

    I have followed all instructions but this doesn't work. I click on the command button and nothing happens.

    Have I done something wrong here?
    Last edited by NeoPa; May 16 '12, 01:59 AM. Reason: Added mandatory [CODE] tags for you.
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    Guess the name change did ruin all.
    Best way:
    1) Place button and cancel the wizard when active.
    2) Use Properties tab Other and set the name to cmdDelete
    3) Use Event tab and doubleclick the OnClick event text, thus "Procedure" will appear with a [...] button.
    4) Press [...] button and enter the command:
    DoCmd.OpenQuery "deletedatafrom job"

    That's all, no other events needed.

    Comment

    • Jennytranxxx
      New Member
      • May 2012
      • 8

      #3
      It works!
      Thanks so much for your help! Thankyou

      Comment

      Working...