Delete records by year problem using VB code (1 Viewer)

Howlsta

Vampire Slayer
Local time
Today, 12:51
Joined
Jul 18, 2001
Messages
180
I have to write a program in VB that will delete some records from a database that the user browses for on a VB form. The user will be able to enter the year that they would like to delete the records from. Then the program will open a recordset and look through a table of accidents and delete all the records with that year in its date field. Another problem is that related records in other tables will also need to be deleted if they have the same accident number(primary key). If cascade deleted records is on will these records disappear anyway or will it be cause an error? If these records won't be deleted what is the best way of getting rid of them?

I think they want me to use VB and not VBA otherwise I could have probably done a delete query I suppose.

I've been told I might be able to right the program in 1 hour it sounds optimistic, especially as I haven't got much idea of how to do it, what do you reckon?

Rich
 

chenn

Registered User.
Local time
Today, 12:51
Joined
Apr 19, 2002
Messages
69
You should be able to open a recordset through ADODB and loop through all the records deleting where the year = the criteria.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:51
Joined
Feb 19, 2002
Messages
43,457
A delete query with criteria is faster. If cascade delete is on, related records will be automatically deleted.
 

Users who are viewing this thread

Top Bottom