Event working on form but not on Navigation Form

bnecrush

New Member
Joined
Nov 26, 2012
Messages
31
I have put a check box on a form that when clicked previews the report for that record. When I perform this on the form it works fine but when I go to the Navigation Page and try it it says "Enter Parameter Value". Why would it work on the form but not on the navigation form? I have tried it several times on both with the same results.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
What's the query source/SQL for the report?
 
Upvote 0
I am very new to access, so I hope this is what you are looking for.


SELECT PurchaseOrder.POID, PurchaseOrder.PurchaseOrderDetailPOID, PurchaseOrder.PONumber, PurchaseOrder.POdate, PurchaseOrder.Vendor, PurchaseOrder.EnteredBy, PurchaseOrder.POPrinted, PurchaseOrder.VendorAddress, PurchaseOrder.VendorCity, PurchaseOrder.VendorState, PurchaseOrder.VendorZip, PurchaseOrder.ContactName, PurchaseOrder.VendorPhone, PurchaseOrder.VendorFax, PurchaseOrder.VendorLeadTime, PurchaseOrder.VendorEmail, PurchaseOrder.VendorDelMethod, PurchaseOrderDetail.PODID, PurchaseOrderDetail.ItemName, PurchaseOrderDetail.ItemNumber, PurchaseOrderDetail.Qty, PurchaseOrderDetail.UnitCost, PurchaseOrderDetail.ExtPrice, PurchaseOrderDetail.TotalDue, PurchaseOrderDetail.PurchaseOrderID, PurchaseOrderDetail.PartDescription
FROM PurchaseOrder INNER JOIN PurchaseOrderDetail ON PurchaseOrder.[POID] = PurchaseOrderDetail.[PurchaseOrderID];


Also this is the code:
Private Sub POPrinted_Click()
DoCmd.RefreshRecord
DoCmd.OpenReport "purchaseOrder", acViewPreview, , "[POID]=forms!PurchaseOrder!POID"
End Sub

Like I said it works on the form when I open the form alone, not through the Navigation Page.


Thanks!!
 
Upvote 0
Hi,

I assume you are using Access 2010 correct? And you're using the new Navigation Form feature as well, correct?

If your form works just fine when opened separately to view the report than you've taken the first step. However, if you open that form "inside" the context of a Navigation Form, you'll probably see this fail if you're using a form reference in perhaps the query driving the report, the macro or VBA code opening the report, etc. The reason this fails is because any form (or report) opened within the context of a Navigation Form is actually being opened as a subform/subreport inside the Navigation Form. When you create a navigation form, it is merely a form with a special subform container. This subform container, or control to be more precise, is what Access uses to swap out other forms and reports into it when you click the navigation tab buttons. So by opening your form *inside* the form called Navigation Form, you need to adjust the references because the form is now a *subform* displayed inside the parent Navigation Form.

So if you have a query for example with a form reference like so:
[Forms]![MyForm]![MyControlOnForm]

You'll need to change that to use syntax like so:
[Forms]![Navigation Form]![NavigationSubform].[Form]![MyControlOnForm]

You'll of course need to substitute [Navigation Form] with the name of the your navigation form and substitute [NavigationSubform] with the subform container name on your navigation form. By default it should be [NavigationSubform] unless you changed that.

Does that make sense?
--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
Copyright
----------
 
Upvote 0
It does make sense. However with my limited knowledge of access I am guessing I would make the change to the code as such:

From: DoCmd.OpenReport "purchaseOrder", acViewPreview, , "[POID]=forms!PurchaseOrder!POID"

To: DoCmd.OpenReport "purchaseOrder", acViewPreview, , "[POID]=forms!NavigationForm!PurchaseOrders!NewPurchaseOrder!POID"

I have the Navigation Form under that there is a tab for Purchase Orders then a tab for New Purchase Orders and one for Purchase Order Reports. Since the form is on the tab "New Purchase Orders" I am assuming there is "one more step"?

Again, just guessing. Thanks for you help so far!
 
Upvote 0
Hi,

You're close, but not quite right.

First question:
What is the name of your navigation form onto which you are placing these forms?
By default, Access named this "Navigation Form" but you could have changed that to something else like Main Menu or Lauch form. I just need to be sure what you called it.

Second question:
What is the name of the subform container within the "Navigation Form"?
By default, it should be NavigationSubform unless you changed it. I just want to be sure here.

To find out the answer to number 2, open your Navgation Form in Layout view. Then select the Property Sheet and look for something called NavigationSubform. Do you see that? Is so, let me know. That's the name we need.

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: Home
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
Copyright
----------
 
Upvote 0
The Navigation Form is called "Navigation Form" and the subform is "NavigationSubform", neither one has been changed.

Glad I am close at least!
:)
 
Upvote 0
Ok that helps, thanks.

Try this:
"[POID]=[Forms]![Navigation Form]![NavigationSubform].[Form]![POID]"

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: Home
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
Copyright
----------
 
Upvote 0
Great, I'm glad to hear you got it working now.

Remember though that since you made this change, if you open your NewPurchaseOrder form by itself and try to open the report it won't work. It will only work inside the navigation form now.

For the benefit of your learning, and any others, the syntax above is what you should follow for any form references if you place the form inside a Navigation Form (2010+ version).

Access (in English here) goes:
Look for a form called Navigation Form.
Within that form, look for a *control* called NavigationSubform (it's actually a suform/subreport control).
Within that subform container grab a reference to the form's collection *currently displayed* within the frame.
Finally, look for a specific control on that form called POID.

You'll notice that no where in that expression did you need to provide the name of the form - NewPurchaseOrder.
That's because the Navigation Form can swap out a bunch of forms (and even reports) within the control. It doesn't need the name of the form; Access will just try and latch onto the form's collection of whatever is currently displaying.

Good luck with your project.

--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation

Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: Home
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
Copyright
----------
 
Upvote 0

Forum statistics

Threads
1,221,825
Messages
6,162,166
Members
451,750
Latest member
dofrancis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top