Results 1 to 7 of 7

Thread: Please Help Me!

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15
    How can I delete all the records of 9 tables?
    All 9 tables are in the same .mdb database.

    I dont't know if I have to use one ADO(or DAO) for each
    table or maybe there is a better way to do that...
    I don't know.

    All I know is that my SQL should look like this:
    "delete from TableName;"

    Anybody please help me
    I'm not like them
    but I can pretend

  2. #2
    Addicted Member
    Join Date
    Jun 2000
    Location
    Pittsburgh, PA
    Posts
    149
    I havent tried this yet but I think you can just use the * wildcard in the sql.
    Code:
    DELETE * FROM *
    if it doesnt work then you will need to take the * of the FROM and do individual tables but I think that should work for you.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15

    Unhappy

    I tryed that but it doesn't work (SQL error)

    Thank anyway

    Anyone can help me?
    I'm not like them
    but I can pretend

  4. #4
    Guest
    try this:
    Code:
    ' this code was taken from 101 Tech Tips by VBPJ
    Function ZapTable(sTable as STring, Optional sWhere as String = "") as Integer
    Dim sSQL as String
    On Error GoTo Err_ZapRecs
      ' For Access Apps only:
      ' docmd.SetWarnings False
      sSQL = "DELETE * FROM " & sTable & " " 
      If sWhere <> "" Then 
        sSQL = sSQL & "WHERE " & sWhere
      End If
      DB.Execute sSQL, dbFailOnError
      ' docmd.SetWarnings True
      ZapTable = True
    Exit_ZapRecs:
      Exit Function
    Err_ZapRecs:
      ZapTable = False
    ''ERROR HANDLING IF DESIRED
       Resume Exit_ZapRecs
    End Function
    hope this helps.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15
    What type is DB in your function?
    I'm not like them
    but I can pretend

  6. #6
    Guest
    whatever database object you have.

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    15

    Thumbs up

    Hooooooooooooo yeah

    thank you billyboy, your help was just what I needed.
    It works perfectly, like I want.

    thank you again
    I'm not like them
    but I can pretend

Posting Permissions

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



Click Here to Expand Forum to Full Width