M
mehmeh via AccessMonster.com
Hi,
I’m having a little problem with my loop.
My aim is for it to keep the first record, delete the next 19, keep the next
record, delete the next 19 etc, until there are no more records (there are
500).
I’ve been given a table with a very dodgy layout so I’m just trying to
extract the data.
This is what I’ve got so far although, as you can tell, it has failed
miserably:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim Time As Long
Time = 1
Do While Time < 501
‘Select next record
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
Time = Time + 1
Loop
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
I need to rewrite the ‘select next record’ bit as I just deleted it by
accident.
I’m having a little problem with my loop.
My aim is for it to keep the first record, delete the next 19, keep the next
record, delete the next 19 etc, until there are no more records (there are
500).
I’ve been given a table with a very dodgy layout so I’m just trying to
extract the data.
This is what I’ve got so far although, as you can tell, it has failed
miserably:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim Time As Long
Time = 1
Do While Time < 501
‘Select next record
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
DoCmd.DeleteObject ("DELETE * FROM Table1 WHERE [ID] = Time")
Time = Time + 1
Loop
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
I need to rewrite the ‘select next record’ bit as I just deleted it by
accident.