Problem with VBA Access - lock files
Hi
I have a problem deleting table thru VBA. Here's how I do it :
VB Code:
t_file.Open "File", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If t_file.EOF = False Then
Do
t_file.Delete
t_file.MoveNext
Loop Until t_file.EOF
End If
t_file.Close
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
Re: Problem with VBA Access - lock files
Moved to Office Development
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:
DoCmd.RunSQL "DELETE * FROM File"
instead of deleting it record by record.
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:
sSQL = "DROP TABLE table_name;"
oConn.Execute sSQL
If you just want to wipe all the records in the table, something like this:
VB Code:
sSQL = "DELETE * FROM table_name;"
oConn.Execute sSQL