Syntax Error in FROM clause

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clloyd
    New Member
    • Mar 2008
    • 91

    #16
    So you are saying the code would read as follows:
    Code:
    Dim MyDB As Database  
    Set MyDB =OpenDatabase "S:\Current\Montey's Restaurant, Inc\Montey's Restaurant\Montey's Restaurant.mdb'")  
    MyDb.Close
    I have numerous tables in this database. I still do not understand how it knows which table to delete from reading the code as I have it above. I am not an expert so if I am missing something I apologize.

    Comment

    • clloyd
      New Member
      • Mar 2008
      • 91

      #17
      I went ahead and tried it removing MyDB.Execute "DELETE FROM MyTable" and still got the Invalid SQL Statement; expected 'Delete', 'Insert', 'Procedure', 'Select', or 'Update' error

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #18
        I think in your code MyTable is the name of the table.

        Comment

        • clloyd
          New Member
          • Mar 2008
          • 91

          #19
          No matter what I do this code does not work. I will keep searching.

          Comment

          • debasisdas
            Recognized Expert Expert
            • Dec 2006
            • 8119

            #20
            do you understand the code ,you have written
            I don't think you understand the difference between a database and a table.
            Please use ADO and follow as per post#8

            Comment

            • clloyd
              New Member
              • Mar 2008
              • 91

              #21
              No I don't understand post 8. I am not an expert programmer. I do understand however the difference between a table and a database though. That was a little harsh.

              Comment

              • debasisdas
                Recognized Expert Expert
                • Dec 2006
                • 8119

                #22
                try something like this

                Code:
                Dim CON As New ADODB.Connection 
                  
                Private Sub Command1_Click() 
                CON.Open "Provider=MSDAORA.1;Password=DEBASIS;User ID=DEBASIS;Data Source=DAS;Persist Security Info=True" --change to your own connectionstring
                CON.BEGINTRANS
                CON.EXECUTE "DELETE FROM TABLE1"  --USE YOUR DELETE STATMENT HERE
                CON.COMMITTRANS
                Endsub

                Comment

                • QVeen72
                  Recognized Expert Top Contributor
                  • Oct 2006
                  • 1445

                  #23
                  Hi

                  Where are you writing the Code..? in VB6 or in VBA...?

                  Regards
                  Veena

                  Comment

                  • clloyd
                    New Member
                    • Mar 2008
                    • 91

                    #24
                    VBA. Sorry to take so long I was on other projects.

                    Comment

                    Working...