Hi Tom,
Here are two versions:
Code:
Public Sub DeleteRecordsFreeForm()
Dim T As TableDef
Dim n As Integer
DoCmd.SetWarnings False
For Each T In CurrentDb.TableDefs
If T.Name Like "FF_*" Then
DoCmd.RunSQL "DELETE * FROM " & T.Name
Select Case T.Fields(0)
Case dbText
MsgBox "text"
DoCmd.RunSQL "INSERT INTO " & T.Name & " (" & T.Fields(0).Name & ", TARGET_TABLE, TARGET_FIELD, COMMENT) VALUES ('M', 'x', 'y', '---');"
Case dbLong
MsgBox "long"
DoCmd.RunSQL "INSERT INTO " & T.Name & " (" & T.Fields(0).Name & ", TARGET_TABLE, TARGET_FIELD, COMMENT) VALUES (0, 'x', 'y', '---');"
End Select
n = n + 1
End If
Next T
DoCmd.SetWarnings True
MsgBox "All records were deleted from " & n & " tables.", vbInformation, "Delete Status"
End Sub
Public Sub DeleteRecordsFreeFormBruteForce()
Dim T As TableDef
Dim n As Integer
DoCmd.SetWarnings False
For Each T In CurrentDb.TableDefs
If T.Name Like "FF_*" Then
DoCmd.RunSQL "DELETE * FROM " & T.Name
On Error Resume Next
DoCmd.RunSQL "INSERT INTO " & T.Name & " (" & T.Fields(0).Name & ", TARGET_TABLE, TARGET_FIELD, COMMENT) VALUES ('M', 'x', 'y', '---');" 'text
DoCmd.RunSQL "INSERT INTO " & T.Name & " (" & T.Fields(0).Name & ", TARGET_TABLE, TARGET_FIELD, COMMENT) VALUES (0, 'x', 'y', '---');" 'number
DoCmd.RunSQL "INSERT INTO " & T.Name & " (" & T.Fields(0).Name & ", TARGET_TABLE, TARGET_FIELD, COMMENT) VALUES (Date, 'x', 'y', '---');" 'Date
End Select
n = n + 1
End If
Next T
DoCmd.SetWarnings True
MsgBox "All records were deleted from " & n & " tables.", vbInformation, "Delete Status"
End Sub
Cheers,