zelarra821
Registered User.
- Local time
- Today, 05:36
- Joined
- Jan 14, 2019
- Messages
- 847
Hello.
I found a code to delete all records from a database:
However, when I run it, and enter a form, the data source is not updated.
I don't know if I might be missing something in the code, such as updating the tables, that's why I'm asking, or is there another way to do it.
Thank you so much.
I found a code to delete all records from a database:
Code:
Public Function empty_tables() As Boolean
'======================================================
' Author: wongm003
' Use to empty all visible tables in current database.
'
' Note: if you do not want to prompt the user for each
' table comment out the second if statement (if msgbox...).
'======================================================
On Error GoTo hndl_err
Dim tbl As Variant
Dim strSQL As String
DoCmd.SetWarnings False
For Each tbl In CurrentDb.TableDefs
If Not Application.GetHiddenAttribute(acTable, tbl.Name) Then
If MsgBox("Empty " & tbl.Name & "?", vbYesNo) = vbYes Then
strSQL = _
"DELETE " & tbl.Name & ".* " & _
"FROM " & tbl.Name & ";"
DoCmd.RunSQL strSQL
End If
End If
Next tbl
empty_tables = True
normal_exit:
DoCmd.SetWarnings True
Exit Function
hndl_err:
empty_tables = False
Resume normal_exit
End Function
However, when I run it, and enter a form, the data source is not updated.
I don't know if I might be missing something in the code, such as updating the tables, that's why I'm asking, or is there another way to do it.
Thank you so much.