Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete all records in to table (2000)

    Is this piece of code correct to dlete all record into table:
    Dim PROVADatabase As Object
    Dim ExportRecordSet As Object
    Dim varTables As Variant
    Set PROVADatabase = New ADODB.Connection
    PROVADatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & gPROVADatabasePath & "'; User Id=admin; Password=;"
    Set ExportRecordSet = New ADODB.Recordset
    ExportRecordSet.Open "EXTRA", PROVADatabase, adOpenKeyset, adLockOptimistic, adCmdTableDirect
    ExportRecordSet.Index = "PROVA2"

    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''this code
    varTables = Array("EXTRA")
    strSQL = "Select * From " & varTables
    strSQLdelete = "Delete * From " & varTables
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''this code

    Sheets("PRESENZE_ACCESS").Range("A5:N2500").ClearC ontents
    Range("A5").Select

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Delete all records in to table (2000)

    If you want to delete all records from the table named EXTRA, use this:

    Dim PROVADatabase As Object
    Set PROVADatabase = CreateObject("ADODB.Connection")
    PROVADatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & gPROVADatabasePath & "'; User Id=admin; Password=;"
    PROVADatabase.Execute "DELETE * FROM EXTRA"
    PROVADatabase.Close
    Set ProvaDatabase = Nothing

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete all records in to table (2000)

    great!
    But if into mdb are present 2 table EXTRA and PROVA and i want to delete all record from the 2 table?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Delete all records in to table (2000)

    You can easily add a line for each table whose records are to be deleted.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete all records in to table (2000)

    Good!...

Posting Permissions

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