snyperj
asked on
Delete all data in certain tables
If I created a table (tbl_temp_tables) of table names, Is there a way I could then run an event that would delete all records in all of the tables I have listed in tbl_temp_tables?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
typo error
change this
currentdb.execute "delete * from " & rs.tableName
with
currentdb.execute "delete * from " & rs!tableName
change this
currentdb.execute "delete * from " & rs.tableName
with
currentdb.execute "delete * from " & rs!tableName
Private Sub btnDelData_Click()
With CurrentDb.OpenRecordset("t bl_temp_ta bles", dbOpenDynaset)
Do Until .EOF
CurrentDb.Execute "DELETE * FROM " & ![TableName]
.MoveNext
Loop
End With
End Sub
Make a BACKUP first ...
mx
With CurrentDb.OpenRecordset("t
Do Until .EOF
CurrentDb.Execute "DELETE * FROM " & ![TableName]
.MoveNext
Loop
End With
End Sub
Make a BACKUP first ...
mx
Forgot the MoveNext. Tres embarrassing :)
<No points wanted>
Whenever I do anything "Destructive" I always feel that it is a good idea to wrap it in some type of "Confirmation" code.
Something roughly like this:
If msgbox("Delete all records?, Are you sure?", vbquestion+vbyesno)=vbno then
Exit Sub
end if
'Your Delete code
JeffCoachman
Whenever I do anything "Destructive" I always feel that it is a good idea to wrap it in some type of "Confirmation" code.
Something roughly like this:
If msgbox("Delete all records?, Are you sure?", vbquestion+vbyesno)=vbno then
Exit Sub
end if
'Your Delete code
JeffCoachman
ASKER
Thanks- this worked so it is what I used.
Open in new window