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

Identifying opend forms

P: n/a
Dear Folks:

Question #1:
I have not been able to find a method to acknowledge or indicate that a
form is open (not necessarily have the focus). Any ideas on how to
check if a particular form is open from VBA?

Question #2:
Is there anyway to trigger an event or DETECT that the Alt key (or any
other key like SHIFT or CTRL) has been pressed down while CLICKING on a
control on a form? This would be similar to other Window applications
where by holding down the Ctrl (Control) key while clicking modifies the
action of simply clicking without depressing the Ctrl key.
Thanks!
Greg Fierro

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 23 Sep 2003 11:02:22 GMT, Greg F. <gr********@yahoo.com> wrote:

1: iterate over the Forms collection.

2: Check out the Keydown event.

-Tom.

Dear Folks:

Question #1:
I have not been able to find a method to acknowledge or indicate that a
form is open (not necessarily have the focus). Any ideas on how to
check if a particular form is open from VBA?

Question #2:
Is there anyway to trigger an event or DETECT that the Alt key (or any
other key like SHIFT or CTRL) has been pressed down while CLICKING on a
control on a form? This would be similar to other Window applications
where by holding down the Ctrl (Control) key while clicking modifies the
action of simply clicking without depressing the Ctrl key.
Thanks!
Greg Fierro

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 12 '05 #2

P: n/a
#1 this is a block of code I came across years ago.

Function FormisLoaded(anyForm As String) As Integer

On Error GoTo FormIsLoaded_Err

' Scan the open forms...
Dim I%
For I% = 0 To Forms.Count - 1
If (Forms(I%).FormName = anyForm) Then
FormisLoaded = True
Exit Function
End If
Next I%

FormisLoaded = False

Exit Function

FormIsLoaded_Err:
msgbox err
Exit Function

End Function
Nov 12 '05 #3

P: n/a
> Question #1:
I have not been able to find a method to acknowledge or indicate that a
form is open (not necessarily have the focus). Any ideas on how to
check if a particular form is open from VBA?
Hehe, just implemented this a few minutes ago! The IsLoaded function
is what you're looking for: it takes the name of a form (as string) as
a parameter and returns true if the form has been loaded and false
otherwise. Keep in mind hidden forms are still considered loaded (but
you could probably distinguish them by calling the visible property).
Question #2:
Is there anyway to trigger an event or DETECT that the Alt key (or any
other key like SHIFT or CTRL) has been pressed down while CLICKING on a
control on a form? This would be similar to other Window applications
where by holding down the Ctrl (Control) key while clicking modifies the
action of simply clicking without depressing the Ctrl key.


I don't remember off the top of my head, but I think there is a method
to check whether or not a key has been depressed. You could call this
function in the OnClick event of the desired controls.

Sorry I couldn't be more specific; I'm a VBA neophyte as well ;p
Nov 12 '05 #4

P: n/a
Dear Andante

I took a look at the list of internal functions in Access 2000 and
couldn't find the IsLoaded function. Could you give me a bit more info
of where you found this "IsLoaded" function?

Thanks!
Greg Fierro

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5

P: n/a
Oops, my bad. IsLoaded is a sample function that was c/p'ed from the
sample Northwind database provided with Access. I took this for
granted that my predecessor pasted this code in a common module I
didn't see before. This code is as follows in Access 97. It should
work with 2000 as well, but you might have to c/p it from the 2000
Northwind; it is located in the "Utility Functions" module:

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or
Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.