I think I have been able to successfully adapt your code to my needs. However, I still have a few problems that I believe stem from me not having a firm grasp on dealing with recordsets. The code appears to run but it ends by saying it cannot run the SQL statement for "Auto". There is no Auto in my table. Secondly, the code takes awhile to run because it runs an Append and Delete query for every employee, regardless of whether or not they have any records. I tried to use what I learned tonight of recordsets to decide if the recordset isnull. However, it does not appear to be working. My full code follows:
On Error GoTo ErrHandler
DoCmd.SetWarnings False
DoCmd.Hourglass True
Dim DB As Database
Dim RST As Recordset
Set DB = CurrentDb
Set RST = DB.OpenRecordset("MaintenanceList")
With RST
.MoveFirst
Do Until RST.EOF
Dim TableName As String
TableName = .Fields("LogsheetID")
Dim CheckTable As Recordset
Set CheckTable = DB.OpenRecordset(TableName)
If Not IsNull(CheckTable) Then
DoCmd.RunSQL "INSERT INTO Logsheet SELECT " & TableName & ".* FROM " & TableName & ";"
DoCmd.RunSQL "DELETE " & TableName & ".* FROM " & TableName & ";"
End If
.MoveNext
Loop
End With
Set RST = Nothing
Set DB = Nothing
Beep
MsgBox "The Maintenance has been completed. Thank you!"
DoCmd.Close acForm, "Maintenance Dialog"
GetOut:
DoCmd.Hourglass False
DoCmd.SetWarnings True
Exit Sub
ErrHandler:
Beep
MsgBox Err.Description
Resume GetOut
Again, any assistance would be greatly appreciated.
[This message has been edited by doulostheou (edited 04-22-2002).]
[This message has been edited by doulostheou (edited 04-22-2002).]