Results 1 to 4 of 4

Thread: Problem with VBA Access - lock files

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    21

    Problem with VBA Access - lock files

    Hi
    I have a problem deleting table thru VBA. Here's how I do it :
    VB Code:
    1. t_file.Open "File", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
    2.  
    3. If t_file.EOF = False Then
    4.     Do
    5.     t_file.Delete
    6.     t_file.MoveNext
    7.     Loop Until t_file.EOF
    8. End If
    9.  
    10. t_file.Close
    11. Set t_file = Nothing

    The problem is that if the table is too big, it tells me that the number of lock file is too big. Is there another way or a problem with what I am doing.

    Thanks for helping

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Problem with VBA Access - lock files

    Moved to Office Development

  3. #3
    Member
    Join Date
    Mar 2006
    Posts
    33

    Re: Problem with VBA Access - lock files

    I would just check to see if the table is empty, like you did, and if it is not, then call
    VB Code:
    1. DoCmd.RunSQL "DELETE * FROM File"
    instead of deleting it record by record.

  4. #4
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Problem with VBA Access - lock files

    If you want to delete the entire table, you can do something like this where oConn is your connection:
    VB Code:
    1. sSQL = "DROP TABLE table_name;"
    2.     oConn.Execute sSQL
    If you just want to wipe all the records in the table, something like this:
    VB Code:
    1. sSQL = "DELETE * FROM table_name;"
    2.     oConn.Execute sSQL

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