Force Access to return to form

Amileaux

Registered User.
Local time
Today, 02:54
Joined
May 6, 2003
Messages
98
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
 
Your VerifyImportErrorTables() function looks very familular to me. ;)

I never have that problem when I use it. I suggest adding a line to the end of the cmdLucentStinger_Click() sub to open the form that you are running the VerifyImportErrorTables() function from.

DoCmd.OpenForm "YourFormNameHere"

HTH
 
It probably looks familiar because I "copied" it from either this website or another one I go to frequently. Anyway - The importError function is in a module so I can "call" it from other forms. The form I want to return to is already open. To clarify:
I open a form, which has 3 command buttons that do different things. One of those command buttons has the code I sent attached to it. When I click that button, access goes off, does it's thing and when it's done it leaves me on the table's tab (because it has deleted my import errors). So, in order for me to click the third button I have to go "find" my already open form and proceed. There must be some way to tell access to return to the form from where I started. Does that make sense? Marie
 
Set the focus to the Form First and then to the control.

ie. Me.SetFocus
 

Users who are viewing this thread

Back
Top Bottom