Howlsta
Vampire Slayer
- Local time
- Today, 02:42
- Joined
- Jul 18, 2001
- Messages
- 180
Hi Access Afficionado's,
I'm trying to knock out some records like so in VB:
sSQL = "DELETE * FROM [Attendant circumstances] WHERE (Year([Date]))LIKE " & MyYear
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [Casualty Details] WHERE [Casualty Details]![Crash Reference] NOT IN (SELECT [Crash Reference] FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [Vehicle Details] WHERE [Vehicle Details]![Crash Reference] NOT IN (SELECT [Crash Reference] FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [PNT_ACCS] WHERE [PNT_ACCS]![PointID] NOT IN (SELECT clng([Accident Key]) FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
is there a quicker way of taking out the records using VB for instance an SQL statement in a similar style to a delete query to take them all out. The guy who is going to use the program will be deleting about 30k records at a time and the above code will do it, but due to the amount of deletions needed it keeps 'not responding' is there any quicker code? It takes ages!!!!
So, to clarify, each table has an accident key; when all the records from a certain year are deleted from attendant circumstances, I delete all the orphaned records from the other tables i.e. records which have an accident key that no longer exists in attendant circumstances.
thanks,
Rich
I'm trying to knock out some records like so in VB:
sSQL = "DELETE * FROM [Attendant circumstances] WHERE (Year([Date]))LIKE " & MyYear
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [Casualty Details] WHERE [Casualty Details]![Crash Reference] NOT IN (SELECT [Crash Reference] FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [Vehicle Details] WHERE [Vehicle Details]![Crash Reference] NOT IN (SELECT [Crash Reference] FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
sSQL = "DELETE FROM [PNT_ACCS] WHERE [PNT_ACCS]![PointID] NOT IN (SELECT clng([Accident Key]) FROM [Attendant circumstances])"
g_DataConnection.Execute sSQL
is there a quicker way of taking out the records using VB for instance an SQL statement in a similar style to a delete query to take them all out. The guy who is going to use the program will be deleting about 30k records at a time and the above code will do it, but due to the amount of deletions needed it keeps 'not responding' is there any quicker code? It takes ages!!!!
So, to clarify, each table has an accident key; when all the records from a certain year are deleted from attendant circumstances, I delete all the orphaned records from the other tables i.e. records which have an accident key that no longer exists in attendant circumstances.
thanks,
Rich
Last edited: