Order of forms loaded

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an app with many diff forms that users can open up. Is there any way
to tell the order that they opened up the forms? I ask because when the user
closes a form and automatically goes back to the previous form, I want to
know what that form is BEFORE they are back at it, so I can refresh a control
on it (this refresh occurs outside the form itself because this same control
is used on many different forms).

Any help would be greatly appreciated.
 
You might be able to loop through the Forms collection (using the numer
index), find the currrent form (the one that matches Me.Name), subtract one
number, and then read the name of that form.

Realistically, that is not a very reliable approach though: if they opened
another form between the two, then it may not in fact be the previous form.

It might be better to pass the name of the calling form in the OpenArgs of
OpenForm. You can then be sure which form called it (if any), and go back to
the right one.

Open it like this:
DoCmd.OpenForm "Form2", "OpenArgs:=" & Me.Name

And then in the Unload event (or possibly AfterUpdate and AfterDelConfirm
events) of the other form:
Dim strCallingForm As String
strCallingForm = Nz(Me.OpenArgs, vbNullString)
If strCallingForm <> vbNullString Then
If CurrentProject.AllForms(strCallingForm).IsLoaded Then
Forms(strCallingForm)!SomeControl.Requery
End If
End If
 
You could write code in the Open or Load event of the Forms to write a log
record, and in the Close event to remove that record. You could put the Log
Table in each user's FrontEnd application for conveniece, or use a single
Table in the BackEnd database, with each entry identified by user. The
second approach would make it somewhat more difficult to use the table as
though it were a "stack" or "heap."

Larry Linson
Microsoft Access MVP
 
Could you just call a function in all the forms' open events to update the
control source? Then the sequence wouldn't matter. All forms would have
current data on open.

HTH, UpRider
 
Back
Top