Running SQL statements with VB 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesse07
    New Member
    • Sep 2007
    • 18

    Running SQL statements with VB 6.0

    I would like to customize running my SQL statement. At this moment, I am using->

    DoCmd.RunSQL strSQL

    This statement will deletes from one of my tables, but instead of getting the standard message box:


    "You are about to delete 1 row(s).

    Once you click Yes, you can’t use the undo command to reverse the changes. Are you sure you want to delete the selected row?

    "

    I would like to customize my own, but I am not sure how to do it. Any suggestions would be greatly appreciated.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Can't you just do a MsgBox before issuing the SQL command?

    Comment

    • jesse07
      New Member
      • Sep 2007
      • 18

      #3
      I can do a message box but the same prompt comes up when I execute the delete from the table

      *************** *************** *************** *****
      You are about to delete 1 row(s).

      Once you click Yes, you can’t use the undo command to reverse the changes. Are you sure you want to delete the selected row?

      *************** *************** *************** ******

      I do not want this prompt to come up, and I believe it is a default with the DoCmd.RunSql. I

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Ok, I think you're telling us fibs here. This isn't VB6, is it? It's VBA, the macro language, in MS Access - right?

        Comment

        • Dan2kx
          Contributor
          • Oct 2007
          • 365

          #5
          If you are in Access you can use

          DoCmd.SetWarnin gs True/False

          And once you have done that you can (well before actually) you can set up a msgbox response.

          I would do it like this

          [on click event](or whatever)
          [CODE=vb]
          dim response as Integer
          dim strSQL as string
          strSQL = ("query code")
          response = msgbox("blah blah",vbokcance l)
          if response = vbok then
          docmd.setwarnin gs false
          docmd.runSQL strSQL
          docmd.setwarnin gs true
          else
          msgbox "Procedure canceled by user"
          end if
          end sub[/CODE]

          Just a suggestion
          Last edited by Killer42; Oct 11 '07, 10:15 PM. Reason: Added [CODE=vb] tag.

          Comment

          Working...