Below is a procedure attached to a button on a form. However, it always ends on my tables tab and not on the form, so to continue I have to click windows, select my open form so I can click the next button. The offending line is the "Call VerifyImportErrorTables" - which I've also listed below. Because the data I'm importing does create Import Errors, this causes access to go to the tables tab to delete the import errors table, however, I want access to return to my form when it is done. I added the cmdLucentStinger.SetFocus, (which is the name of the command button on the form), but that isn't working. Any ideas? Thank you. Marie
Private Sub cmdLucentStinger_Click()
DoCmd.Hourglass True
DoCmd.SetWarnings False
Call DeleteOldLucentIntegratorTable
Call GetLucentStinger
Call ImportLucentIntegrator
Call LucentIntegratorDeleteRows
Call VerifyImportErrorTables
DoCmd.Hourglass False
cmdLucentStinger.SetFocus
MsgBox "Done with Lucent Integrator Report"
DoCmd.SetWarnings True
End Sub
Public Function VerifyImportErrorTables()
On Error GoTo Err_VerifyImportErrorTables
Dim tblDef As TableDef
For Each tblDef In CurrentDb.TableDefs
If InStr(1, tblDef.Name, "ImportError") > 0 Then
DoCmd.SelectObject acTable, tblDef.Name, True
DoCmd.DeleteObject acTable, tblDef.Name
End If
Next tblDef
Exit_VerifyImportErrorTables:
Exit Function
Err_VerifyImportErrorTables:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_VerifyImportErrorTables
End Function
Private Sub cmdLucentStinger_Click()
DoCmd.Hourglass True
DoCmd.SetWarnings False
Call DeleteOldLucentIntegratorTable
Call GetLucentStinger
Call ImportLucentIntegrator
Call LucentIntegratorDeleteRows
Call VerifyImportErrorTables
DoCmd.Hourglass False
cmdLucentStinger.SetFocus
MsgBox "Done with Lucent Integrator Report"
DoCmd.SetWarnings True
End Sub
Public Function VerifyImportErrorTables()
On Error GoTo Err_VerifyImportErrorTables
Dim tblDef As TableDef
For Each tblDef In CurrentDb.TableDefs
If InStr(1, tblDef.Name, "ImportError") > 0 Then
DoCmd.SelectObject acTable, tblDef.Name, True
DoCmd.DeleteObject acTable, tblDef.Name
End If
Next tblDef
Exit_VerifyImportErrorTables:
Exit Function
Err_VerifyImportErrorTables:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_VerifyImportErrorTables
End Function