What event should I use?

D

DawnTreader

Hello All

I have been working to get my main user form to control the timing of a pop
up form that shows critical information. the first form, frmMainForm is
supposed to load and then at some point cause the second popup modal dialog
form, frmAttentionNeeded to open.

after the user closes the frmAttentionNeeded, i dont want it to open again
during that user session. the problem is i have tried to call the
frmAttentionNeeded in the load, current, open of the frmMainForm and there
are certain factors that cause this to not work well for my situation. so i
used the onfocus event of a control on the frmMainForm and that works but
causes a secondary problem. everytime the user clicks into that field the
second form reopens. i have tried creating a method to not open the second
form again, but the first time the second form opens the frmMainForm hasnt
fully loaded and so the system i created falls apart in that the form will
open twice a session.

this is all really frustrating because i cant seem to figure out the exact
sequence of events for a form and its data. is there any flow chart out there
or some diagram or list that shows EXACTLY how the events flow?

M$ has a description here:

http://office.microsoft.com/en-us/access/HP051867611033.aspx

but they really dont lay it out in a way that makes a fluid sense of the
flow of events. additionally there are a lot of events that they dont even
talk about, afterrender and others.

if anyone knows where i can find a complete "diagram" please post here.

beyond that, is there a way to create a routine to control things to make
this work?

i want all the information for the current record in the frmMainForm to be
fully loaded and then my second frmAttentionNeeded to open. otherwise the
queries in the frmAttentionNeeded dont get some filters filled and the form
is worthless.

anyone with suggestions please pst.
 
M

Marshall Barton

DawnTreader said:
I have been working to get my main user form to control the timing of a pop
up form that shows critical information. the first form, frmMainForm is
supposed to load and then at some point cause the second popup modal dialog
form, frmAttentionNeeded to open.

after the user closes the frmAttentionNeeded, i dont want it to open again
during that user session. the problem is i have tried to call the
frmAttentionNeeded in the load, current, open of the frmMainForm and there
are certain factors that cause this to not work well for my situation. so i
used the onfocus event of a control on the frmMainForm and that works but
causes a secondary problem. everytime the user clicks into that field the
second form reopens. i have tried creating a method to not open the second
form again, but the first time the second form opens the frmMainForm hasnt
fully loaded and so the system i created falls apart in that the form will
open twice a session.

this is all really frustrating because i cant seem to figure out the exact
sequence of events for a form and its data. is there any flow chart out there
or some diagram or list that shows EXACTLY how the events flow?


Events are triggered in response to user actions and state
changes. Forms can change states in various ways depending
on the details of the form's design (e,g, subforms, data
loading (if bound), etc) so there is no such thing as a
definitive "flow".

In your case, I think you want to use the form's Current
event. The important part of that is how to only do it
once.

Static HasBeenOpened As Boolean
If Not HasBeenOpened Then
DoCmd.OpenForm . . .
HasBeenOpened = True
End If
 
D

Damon Heron

Try the current event of the main form. Then put a global variable in the
form module, a boolean
I've called "MyVar". In the current event:
if not (MyVar) then 'myvar is the boolean variable
docmd.openform "frmAttentionNeeded"
MyVar=true 'Setting the boolean to true prevents the form
'from opening again during this session.
end if


Damon
 
D

DawnTreader

Hello Marshall

oh wow. and here i was trying to "store" something on the main form to know
that it has opened the second form. i put a text box on the form that code
put in a value to and looked at that each time the second form was opened.

which form do i put that code on, the main form i assume. is that variable a
property of forms? where does the variable go?

thanks for your help, and yours too Damon!
 
M

Marshall Barton

Yes, put the code in the main form's Current event
procedure. The static variable goes right where I have it,
in the same Current event procedure, which is why using a
local static variable is preferred over a module or global
level variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top