By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Is there a way to detect when a particular form is opened?

P: n/a
I've got two forms, Form1 and Form2. Form1 opens invisibly when the database opens. From Form1 (or from a regular module or class module accessed by Form1), is there a way to detect when Form2 opens?

I'm restricted to only coding in Form1 (or a regular module or class module accessed by Form1). The code can't be in another Form's module, and can't be in the application's startup module fired by the AutoExec macro. That's already being used for a different purpose.

I know the restriction makes it hard but that's what I have to work with. Please let me know if you know a way. I'll write an add-in if I have to but would rather avoid that.
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
> "joebob" <jo****@zipcon.n0t> wrote in message
news:SZ********************@comcast.com...
I've got two forms, Form1 and Form2. Form1 opens invisibly when the
database opens. From Form1 (or from a regular module or class module
accessed by Form1), > is there a way to detect when Form2 opens?


Using a timer in Form1, poll the loaded status of Form2 with the IsLoaded
function at http://www.mvps.org/access/forms/frm0002.htm

But really, you would be much better have having Form2 announce that it has
loaded.
Nov 13 '05 #2

P: n/a
Timer is good enough for what I'm doing. On the Form_Open event I go
Me.TimerInterval = 250 and on the Form_Timer event I go

If IsLoaded("Form2") Then DoCmd.Close acForm, "Form2": Me.TimerInterval = 0

This only happens once just after startup so it's sufficient. Thanks

"John Winterbottom" <as******@hotmail.com> wrote in message
news:2t*************@uni-berlin.de...
"joebob" <jo****@zipcon.n0t> wrote in message
news:SZ********************@comcast.com...
I've got two forms, Form1 and Form2. Form1 opens invisibly when the
database opens. From Form1 (or from a regular module or class module
accessed by Form1), > is there a way to detect when Form2 opens?
Using a timer in Form1, poll the loaded status of Form2 with the IsLoaded
function at http://www.mvps.org/access/forms/frm0002.htm

But really, you would be much better have having Form2 announce that it

has loaded.

Nov 13 '05 #3

P: n/a
joebob wrote:
Timer is good enough for what I'm doing. On the Form_Open event I go
Me.TimerInterval = 250 and on the Form_Timer event I go

If IsLoaded("Form2") Then DoCmd.Close acForm, "Form2": Me.TimerInterval = 0

This only happens once just after startup so it's sufficient. Thanks


It's a weird program you have there. If I understand you correctly, you
want to check every 1/4 second that a certain form is not open and if it
is open, close it. After that, you don't care if it gets opened again
since you set the timer to 0. Why don't you remove all references to
Form2? In fact, why not remove it from the mdb?

Nov 13 '05 #4

P: n/a
"Salad" <oi*@vinegar.com> wrote in message
news:V4****************@newsread3.news.pas.earthli nk.net...
joebob wrote:
Timer is good enough for what I'm doing. On the Form_Open event I go
Me.TimerInterval = 250 and on the Form_Timer event I go

If IsLoaded("Form2") Then DoCmd.Close acForm, "Form2": Me.TimerInterval = 0
This only happens once just after startup so it's sufficient. Thanks


It's a weird program you have there. If I understand you correctly, you
want to check every 1/4 second that a certain form is not open and if it
is open, close it. After that, you don't care if it gets opened again
since you set the timer to 0. Why don't you remove all references to
Form2? In fact, why not remove it from the mdb?

Yes it's weird. It's not my form and it needs to stay in the mdb and open
automatically. I just want to close the f%*#er when it pops up and then it
won't bug me again unless I manually open it.
Nov 13 '05 #5

P: n/a
joebob wrote:
"Salad" <oi*@vinegar.com> wrote in message

It's a weird program you have there. If I understand you correctly, you
want to check every 1/4 second that a certain form is not open and if it
is open, close it. After that, you don't care if it gets opened again
since you set the timer to 0. Why don't you remove all references to
Form2? In fact, why not remove it from the mdb?


Yes it's weird. It's not my form and it needs to stay in the mdb and open
automatically. I just want to close the f%*#er when it pops up and then it
won't bug me again unless I manually open it.


It reminds me of a Whack-A-Mole. :-)

It's too bad the module/macro that opens it can't be modified to open it
hidden. Then you would not need the timer. Or have Form2 open and in
the OnOpen even check OpenArgs and if Null, Cancel it. It the area
OpenArgs has something (called manually) then open it.

Sometimes ya gotta do what you gotta do.
Nov 13 '05 #6

P: n/a
"joebob" <jo****@zipcon.n0t> wrote in message news:<SZ********************@comcast.com>...
I've got two forms, Form1 and Form2. Form1 opens invisibly when the
database opens. From Form1 (or from a regular module or class module
accessed by Form1), is there a way to detect when Form2 opens?

I'm restricted to only coding in Form1 (or a regular module or class
module accessed by Form1). The code can't be in another Form's module,
and can't be in the application's startup module fired by the AutoExec
macro. That's already being used for a different purpose.

I know the restriction makes it hard but that's what I have to work
with. Please let me know if you know a way. I'll write an add-in if I
have to but would rather avoid that.
--


Searching this Group for Detect form you will find some code similiar
to this.

Dim i As Integer
Const FORM_DESIGN = 0

For i = 0 To Forms.Count - 1
If Forms(i).FormName = "frmAdminMenu" Then
If Forms(i).CurrentView <> FORM_DESIGN Then
' do something here
i = Forms.Count ' end the for loop
End If
End If
Next

I used this to find which form is loaded so I could reset the focus to
the proper form without making several versions of the same form.
There is probably an easier way to do what I'm trying to do but this
was quick.

Might help you.

Billie Kennedy
http://www.nuketemplate.com
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.