Share via

Command Button Wizard & delete queries

Anonymous
2011-12-20T16:13:55+00:00

In Access 2010, the command button wizard does not show (or allow) any delete queries.  What gives?  Is there some obscure trick related to trust & security (like having to choose to show all actions in the macro design window).  And yes, i know i could

  • and can - write a piece of code or a macro and assign that to a button, but it would be easier & faster if i could just use the wizard.
Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-12-20T17:13:04+00:00

Running a Delete query can be too complex for the simple minded wizards to deal with.  Creating a button's Click event procedure to do it might be as easy as:

CurrentDb.Execure "DELETE * FROM somethable WHERE somecriteria", dbFailOnError

Or, depending on how you have to identify the record to be deleted and where the table is located, it might take many lines of code.

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-12-20T23:39:12+00:00

    Well. I'll be dipped.  I never noticed that. and I'm glad you pointed that out.  All I can do is guess that MS decided Delete queries are too dangerous to let a wizard do it  :-\

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2011-12-20T19:15:47+00:00

    Aha!  that

         ("you can use the Miscelleanous - Run Query wizard and the select your Delete query from the list of queries.")

    is EXACTLY what you can no longer do.  Microsoft has eliminated the delete queries from the list of queries. 

    And that has really been my only point here.  I could - and did - find an alternative solution, and there are many more, as you have pointed out.  But for a quick and dirty solution, the Wizard sometimes works for me.

    thanks for your help.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-12-20T18:57:16+00:00

    Well if you just want the wizard to run a saved query, you can use the Miscelleanous - Run Query wizard and the select your Delete query from the list of queries.

    My problem with that is that, AFAIK, there is no way to specify the criteria to select the record to be deleted so you have to use single purpose query with a form reference to the text box with the record's PK. 

    I am not trying to be argumentative either, but, for me, it's easier to avoid most of the wizards and just type the code instead of wandering through the wizard's category/action/query selection  dialogs.  Besides, I think the wizard normally generates macros in A2010 and I have a strong dislike for macros, even the new, expanded macro features introduce because web forms (via Share Point) can not use VBA.  Also, the macros essentially use RunQuery which does not wait for the query to complete before letting your application continue (the Execute method is synchronous).

    But it is your app and if that's how you like to do things, go ahead.  I'm just trying to make you aware of alternatives and nuances.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-12-20T17:52:15+00:00

    Well, yes, that is a solution, and a neat, simple one. But in previous versions of Access, you could use the Command Button Wizard in form-design and simply choose an existing [delete] query from your list of queries.   When you are doing a quick-and-dirty job, using the wizards is often a great time saver, and very simple. (otherwise, why would microsoft have them at all?) 

    The wizard is only used to structure and write the procedure associated with the button;  it is not used to run the procedure.  So i don't understand why it could be "too complex for the simple minded wizards to deal with."   In this case, we are talking about 2 arguments: action: run a query;  argument: name of the query. 

    I don't mean to be argumentative, i am just trying to understand the new way of working in Access (my last version was almost 10 years old, so i am behind by 2 versions, and a lot has changed!) 

    Thanks for your help and the snippet of code.

    Was this answer helpful?

    0 comments No comments