Function UnDelete_FS(Optional varUnDeletedTable As Variant) _
As Boolean
Dim db As Database
Dim strSQL As String
Dim strTablename As String
Dim intI As Integer
On Error GoTo Err_UnDelete_FS
Set db = CurrentDb
UnDelete_FS = False
For intI = 0 To db.TableDefs.Count - 1
strTablename = db.TableDefs(intI).Name
If Left(strTablename, 4) = "~tmp" Then
strSQL = "SELECT DISTINCTROW [" & strTablename & _
"].* INTO [" & varUnDeletedTable & _
"] FROM [" & strTablename & "];"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
UnDelete_FS = True
Exit For
End If
Next intI
Exit_UnDelete_FS:
Set db = Nothing
Exit Function
Err_UnDelete_FS:
MsgBox Err.Description
Resume Exit_UnDelete_FS
End Function