Ask Experts Questions for FREE Help !
Ask
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #1

    Mar 21, 2010, 12:07 AM
    Delete Query
    Hi ,
    In My project (Access 2007) , I Used a "Delete Query" To Delete A Record.
    When The Query Is Runnig ,It Ask About Deleting A Record.
    Can We Umit That Message?(In Other Hand , It Delete A Record Without Asking)

    Thanks.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Mar 21, 2010, 02:24 AM

    How are you triggering the query?
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #3

    Mar 21, 2010, 11:37 AM

    What do you mean?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Mar 21, 2010, 11:51 AM

    A Delete query is an Access object that removes records from a table. To run a Delete query, you have to trigger it in some way. You could simply double click the query name in the Navigation Pane or you can call the query from a macro or on a button on a form.

    If you are just running it from the Nav Pane, then there is no way to turn off the Warnings. If, you run it from a macro or from a VBA module, there are ways to turn off the warnings. That's why I asked how you trigger it so I can know what the best way to tell you how to do it is.

    It would also help to know what record you are deleting or to see the SQL for the query. You would have to be providing some criteria for the query so you don't delete all the records in the table.
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #5

    Mar 21, 2010, 12:27 PM

    I click a button that it run a macro.
    And criteria is : [Forms]![main_form]![Txt_del]
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #6

    Mar 21, 2010, 02:39 PM

    Ok, In the macro add a line before you execute the query:

    SetWarnings False

    After the query add a line:

    SetWarnings True
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #7

    Mar 21, 2010, 11:22 PM

    I Tried , But I couldn't.
    The Macro is Like The Follow , Can you Explain More ?

    Macro Name :
    Condition :
    Action : OpenQuery
    Argument :Q_Del,DataSheet,ReadOnly
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #8

    Mar 22, 2010, 03:59 AM

    I generally do not use macros they are too limiting. But in a macro each action is a line. What you show above is is the OpenQuery line. You need to ADD lines above and below that line to turn SetWarnings on and off.

    The VBA code would be:

    SetWarnings False
    DoCmd.OpenQuery "Q_Del"
    SetWarnings True

    You don't need the other parameters for the OpenQuery method as they are the defaults.
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #9

    Mar 22, 2010, 08:21 AM

    I Added That Two Line , And The Result was This Error :

    Compile Error: Sub Or Function Not Defined.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #10

    Mar 22, 2010, 09:25 AM

    You added them to the macro? Did you pick SetWarnings from the list of Actions?
    znet2705zc's Avatar
    znet2705zc Posts: 34, Reputation: 1
    Junior Member
     
    #11

    Mar 23, 2010, 12:55 PM

    No, I didn't.
    Now I do that , and finally it solve.

    Thanks a lot.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #12

    Mar 23, 2010, 01:36 PM

    You're welcome

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Cannot Delete E-mail from My Delete Mail Folder [ 2 Answers ]

I cannot delete certain e-mail from my Delete e-mail folder. I am running Vista with Microsoft Mail. The error message reads "Unknown Error" Thanks MisterJ

DNS Query Query. A Query about DNS Queries... [ 12 Answers ]

I am a software developer, I don’t know much about networks. I have a working network but with one weird (well to me it’s weird) problem. If you can offer any insight I’ll be very grateful! <!--- Image Attachment Below (I couldn't find a way to paste it here in the editor :-( ) ---> ...


View more questions Search