By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

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

P: 8
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:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub deletedatafromjob_Click()
    2. DoCmd.OpenQuery "deletedatafromjob"
    3. MsgBox "Code run"
    4. End Sub
  4. Then in the Build Event option, I have put in:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub deletedatafromjob_Click()
    2. DoCmd.OpenQuery "deletedatafromjob"
    3. MsgBox "Code run"
    4. End Sub
My Delete query name is deletedatafromjob

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?
May 15 '12 #1

✓ answered by nico5038

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 "deletedatafromjob"

That's all, no other events needed.

Share this Question
Share on Google+
2 Replies


nico5038
Expert 2.5K+
P: 3,072
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 "deletedatafromjob"

That's all, no other events needed.
May 15 '12 #2

P: 8
It works!
Thanks so much for your help! Thankyou
May 16 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.