Prev: supress record has been changed by another user warning
Next: Update Links that are password protected.
From: Cevin on 9 Mar 2010 16:38 Thanx for all the help I received. Due to your suggestions, I was able to get the application to do what I wanted it to do. Below is the code that is a seperate module (basCloseWindow) and is called whenever the user closes a window. It does 3 things: -It tests to be sure the first object is still loaded. -It takes them back to the first object (report or form) that they opened the second object from. -It then closes the second object. The 2 variables are sent to the module from the closing form. They are arrived by: -The strCallerWindow is passed to the second object, from the first object, when opened via OpenArgs. -The strCurrentWindow is set when the second object opens by a hard coded line with the objects name. During the development, I realized I also had to allow for the chance that the user may have closed the first form, which would leave them with a blank window. So there is code to test to be sure the first object is still loaded. Thanx again for all your help. I know I'll be reading this group a lot and sure I'll be posting more questions. Cevin '********************************************************* '* Procedure to close the current window and return user to previous window * '********************************************************* Option Compare Database Option Explicit Public Sub CloseWindow(strCallerWindow, strCurrentWindow) On Error GoTo Err_CloseWindow 'Determine if the object to return to is loaded ' Returns True if the specified form is open in Form view or Datasheet view. Dim oAccessObject As AccessObject 'Determine if the object to return to is a form or report If Left(strCallerWindow, 3) = "frm" Then 'it is a form Set oAccessObject = CurrentProject.AllForms(strCallerWindow) Else 'it is a report Set oAccessObject = CurrentProject.AllReports(strCallerWindow) End If If oAccessObject.IsLoaded Then 'calling object is loaded 'Object is loaded - do nothing Else 'Object is NOT loaded - load it If Left(strCallerWindow, 3) = "frm" Then 'it is a form DoCmd.OpenForm strCallerWindow, acNormal, , , _ acFormPropertySettings, acWindowNormal Else 'it is a report DoCmd.OpenReport strCallerWindow, acViewNormal, , , acWindowNormal End If End If 'Move focus to the calling object 'Determine if the object to return to is a form or report If Left(strCallerWindow, 3) = "frm" Then 'it is a form DoCmd.SelectObject acForm, strCallerWindow, True Else 'it is a report DoCmd.SelectObject acReport, strCallerWindow, True End If 'Close the current form 'Determine if the object to close is a form or report If Left(strCurrentWindow, 3) = "frm" Then 'it is a form DoCmd.Close acForm, strCurrentWindow, acSaveNo Else 'it is a report DoCmd.Close acReport, strCurrentWindow, acSaveNo End If 'No errors so exit the subroutine Exit Sub 'Error Handling Err_CloseWindow: 'Display error message for any errors encountered MsgBox Err.Number & ", " & Err.Description, vbCritical + vbOKOnly, "Notify Administrator" End Sub
First
|
Prev
|
Pages: 1 2 Prev: supress record has been changed by another user warning Next: Update Links that are password protected. |