Results 1 to 8 of 8
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528

    Cancel Message or Replaced

    Hi guys
    I have a question
    Can I cancel this message or replaced.
    With a deletion, or a message appears (Yes/cancel) only.
    I hope to help.
    Greetings Azar


    Attached Thumbnails Attached Thumbnails A1.JPG  

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    if you are running a query by opening it manually - then no

    if you are running from vba use currentdb.execute rather than docmd.runsql

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you Ajax
    I use this code in order to delete an invoice
    Code:
    Private Sub Command47_Click()
    On Error GoTo Command47_Click_Err
        On Error Resume Next
        DoCmd.GoToControl Screen.PreviousControl.Name
        Err.Clear
        If (Not Form.NewRecord) Then
            DoCmd.RunCommand acCmdDeleteRecord
        End If
        If (Form.NewRecord And Not Form.Dirty) Then
            Beep
        End If
        If (Form.NewRecord And Form.Dirty) Then
            DoCmd.RunCommand acCmdUndo
        End If
        If (MacroError <> 0) Then
            Beep
            MsgBox MacroError.Description, vbOKOnly, ""
                End If
    Command47_Click_Exit:
        Exit Sub
    Command47_Click_Err:
        MsgBox Error$
        Resume Command47_Click_Exit
    End Sub

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    so use

    currentdb.execute "DELETE * FROM myTable WHERE tblID=" & me.tblID

    change the bits in red to the appropriate names

  5. #5
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    I've used it the way
    currentdb.execute rather than docmd.runsql
    Shows me this error

    What is the solution Thanks in advance
    Attached Thumbnails Attached Thumbnails ddddd.JPG  

  6. #6
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    <p>Thank you so much Ajax <br>&nbsp;It was a mistake in the name of the table, instead of a query must be Workorders <br>
    Code:
    <br>Private Sub Command49_Click()<br>If MsgBox(Prompt:="My question", Buttons:=vbYesNo) = vbYes Then<br>&nbsp;CurrentDb.Execute "DELETE FROM Workorders WHERE WorkorderID=" &amp; Me.WorkorderID<br>&nbsp;Else<br>&nbsp;MsgBox "Delete canceled"<br>&nbsp;End If</p><p>End Sub<br><br>
    </p>

  7. #7
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    528
    Thank you so much Ajax
    It was a mistake in the name of the table, instead of a query must be Workorders
    Private Sub Command49_Click()
    If MsgBox(Prompt:="My question", Buttons:=vbYesNo) = vbYes Then
    CurrentDb.Execute "DELETE FROM Workorders WHERE WorkorderID=" & Me.WorkorderID
    Else
    MsgBox "Delete canceled"
    End If
    End Sub

  8. #8
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    no problem

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

Similar Threads

  1. Replies: 2
    Last Post: 03-19-2015, 01:33 PM
  2. Replies: 5
    Last Post: 05-27-2014, 02:44 PM
  3. Y N cancel message box
    By cantord in forum Forms
    Replies: 8
    Last Post: 11-28-2012, 02:20 PM
  4. Yes/No/Cancel Message Box
    By lynnmc26 in forum Access
    Replies: 0
    Last Post: 04-01-2011, 07:26 PM
  5. Table elements being replaced
    By HurrMark in forum Forms
    Replies: 0
    Last Post: 09-15-2008, 07:53 AM

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