I realise that both the IsLoaded function and the issue of how to refer to sorms and subforms are covered extensively in these forums, but I've trawled through and tested many of the suggestions and still cannot get Access (I'm using Access 2002) to do what I'd have thought should be a pretty simple task. Please bear with me if you think I should have looked harder!
All I want to do is: I have a main form (Main Form) which contains two separate subforms; when the "On Current" event occurs in one of the subforms (Subform 1), I need to find out if the other (Subform 2) is loaded.
I know that the IsLoaded function is working because when I try the following code in Subform 1's On Current event I get a positive result:
If IsLoaded("Main Form") Then
MsgBox ("It's loaded")
End If
I've tried several variations of references to Subform 2, resulting in almost as many different error messages. For instance:
- If IsLoaded(Me.Parent("Subform 2")) Then : error 13 Type mismatch
- If IsLoaded(Me.Parent!("Subform 2")) Then : Type declaration character does not match declared data type
- If IsLoaded(Forms![Main Form]![Subform 2]) Then : error 450 Wrong number of arguments or invalid property assignment
- If IsLoaded(Forms![Main Form].[Subform 2]) Then : error 13 Type mismatch
As I say, I suspect this is actually very simple. Any ideas what I'm doing wrong (and, more importantly, what I should be doing to get it right!)?
All I want to do is: I have a main form (Main Form) which contains two separate subforms; when the "On Current" event occurs in one of the subforms (Subform 1), I need to find out if the other (Subform 2) is loaded.
I know that the IsLoaded function is working because when I try the following code in Subform 1's On Current event I get a positive result:
If IsLoaded("Main Form") Then
MsgBox ("It's loaded")
End If
I've tried several variations of references to Subform 2, resulting in almost as many different error messages. For instance:
- If IsLoaded(Me.Parent("Subform 2")) Then : error 13 Type mismatch
- If IsLoaded(Me.Parent!("Subform 2")) Then : Type declaration character does not match declared data type
- If IsLoaded(Forms![Main Form]![Subform 2]) Then : error 450 Wrong number of arguments or invalid property assignment
- If IsLoaded(Forms![Main Form].[Subform 2]) Then : error 13 Type mismatch
As I say, I suspect this is actually very simple. Any ideas what I'm doing wrong (and, more importantly, what I should be doing to get it right!)?