Navigation subform not loading underlying form

harmankardon

Registered User.
Local time
Today, 09:48
Joined
Aug 8, 2011
Messages
71
Hello all,

I have a form called frmDataEntry that is used for entering data.

I also have a navigation form called frmNavigation that has a series of navigation buttons (using the new Access 2010 nagivation controls) and a navigation subform control.

When you click on one of the navigation buttons (which are setup as a row of tabs at the top of frmNavigation), a form will be loaded into the navigation subform control.

I have a navigation button called btnDataEntry and when clicked, loads frmDataEntry into the navigation subform control.

This part all works as expected. The problem I am having is that when frmDataEntry is loaded into the navigation subform control, the .IsLoaded property of frmDataEntry remains False, whereas if I open frmDataEntry independently of the navigation form, the .IsLoaded property becomes True.

This is a problem because I have created a custom right-click shortcut menu for frmDataEntry that has a control which runs a function that is located in frmDataEntry's code module. The .OnAction property of the menu control is setup as follows:

Code:
Set cmbControl = .Controls.Add(msoControlButton)
            cmbControl.Caption = "UpRev This Drawing"
            cmbControl.BeginGroup = True
            cmbControl.OnAction = "=ReserveDrawing()"

This right-click functionality works great when frmDataEntry is opened indenpendatly of the navigation form (I can right-click on a record and click on my menu control to run the ReserveDrawing fuction), but when I open it through the navigation from and try to use the menu control that runs the above function, I get an Access error saying it can't find the function. Note that making the ReserveDrawing function Public doesn't help because as far as Access is concerned, the .IsLoaded property is false for frmDataEntry, so frmDataEntry's code module is not available.

Has anyone experienced similar problems?

I think the only solution is to move the ReserveDrawing function to it's own global module, which isn't ideal because then I have to pass about 20 variables to the function (assuming I'm even able to pass them in the first place due to the form .IsLoaded being false, even though I can see the form on my screen).
 
a subform is not part of the forms collection. when embedded as subform, all external references to obejcts on this subform form need to be in full , ie forms!parentform!subform!form ..etc
 
So how do I put a full reference to the ReserveDrawing() function in the .OnAction property of my right-click menu button? And can I do a full external reference to function in a form's code module even if that form's .IsLoaded property = False?

I have done full reference to form controls but never to form functions.
 
So how do I put a full reference to the ReserveDrawing() function in the .OnAction property of my right-click menu button

You prefix the function with the full reference, just like any other object. But the function must be made Public (instead of the defualt Private) to be callable from outside the form in which it is defined.

? And can I do a full external reference to function in a form's code module even if that form's .IsLoaded property = False?
One more time. A subform DOES NOT exist in the forms collection. It exists as an object way down the object hierarchy starting at the form in which it is embedded as subform. So forget this .IsLoaded thing. When the parent is loaded, then the subform is also.
 
OK, I think I am starting to understand now, thank you for all your help so far.

What I need to do then is change the .OnAction property of my menu control to a full reference.

Right now it is:

Code:
cmbControl.OnAction = "=ReserveDrawing()"

And if I understand correctly, it needs to be something like this:

Code:
cmbControl.OnAction = "=Forms!MDL_UPREV.Form.ReserveDrawing()"

I know my syntax is incorrect because I receive an error that "Access can't find the field 'ReserveDrawing' referred to in your expression".

I can't seem to find any information on full referenced functions :(
 
OK, finally got it figured out.

What I did was I kept the actual function I wanted to run in frmDataEntry's module (Function name: ReserveDrawing), then I created a standard module and inside that module I created a public function called modReserveDrawing and then I changed.OnAction property for my right click menu button to:

Code:
cmbControl.OnAction = "=modReserveDrawing()"

The code for the modReserveDrawing function is:

Code:
Public Function modReserveDrawing()
    If CurrentProject.AllForms("frmDataEntry").IsLoaded = False Then
        Call Forms("frmNavigation").NavigationSubform.Form.ReserveDrawing
    Else
        Call Forms("frmDataEntry ").ReserveDrawing
    End If
End Function

This way it works both ways (opening form directly or opening form as a navigation subform).
 

Users who are viewing this thread

Back
Top Bottom