Consulting

Results 1 to 6 of 6

Thread: Solved: Delete Action Query problem

  1. #1
    VBAX Regular
    Joined
    May 2005
    Posts
    62
    Location

    Solved: Delete Action Query problem

    hi all helpers,

    got a problem on Delete all records in a table ABC, coding as below, appreciate any adv....tks a lot.

    [VBA]Dim myDB As DAO.Database
    Dim myTable As String
    Dim mySql As String

    myTable ="ABC"

    Set myDB = CurrentDb
    'mySql = "DELETE * FROM " & myTable ' have tried this but not work

    mySql = "DELETE " & myTable & ".* FROM " & myTable

    myDB.Execute (mySql)[/VBA]

    beginner

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    What's the actual problem?

  3. #3
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    hey, beginner

    I don't see a problem here either. What line is generating the error and what's the error?

    Also, have you tried...

    [VBA] docmd.runsql MySql[/VBA]

    That doesn't required DAO.

  4. #4
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    I split this into two threads when you asked your new question, but I didn't know how to split your post up, so I'm putting it here myself.

    Quote Originally Posted by beginner
    hello Norie and xCav8r,

    finally i found the problem is due to my table name's format xxx-xxxx-xxx which give out the error (saying ...syntax wrong in the From sentence...etc.) and can solved finally by enclosed bracket [ ] as below. tks for adv.

    [VBA]Set myDB = CurrentDb
    myTable ="[xxx-xxxx-xxx]"
    mySql = "DELETE " & myTable & ".* FROM " & myTable
    myDB.Execute (mySql) [/VBA]

  5. #5
    VBAX Regular
    Joined
    May 2005
    Posts
    62
    Location
    hi xCav8r,

    thanks for your help for splitting but i didn't see my new question thread in the thread list, or do you mean i need to re-post my new question again ?

    Tks
    beginner

  6. #6
    VBAX Regular
    Joined
    May 2005
    Posts
    62
    Location
    hi xCav8r......i found that thread already, thanks a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •