Share via

Access 2010 - Navigation Form - Subform Issues

Anonymous
2010-08-05T02:42:22+00:00

I have a basic form with combo boxes.  A button on the form calls a report that uses the values of those combo boxes during generation.  For example, in my code for the report, I have:

If Form![frm_CaseListing]!cbo_Admin = "Criteria" Then ....

This code works fine when I open the regular form.  However, when I try to put this form into a Navigation Form, it becomes a subform.  When I try to call the report from the subform, it gives me an error that the form in the code does not exist.  Is there a way to code the report so that it would work as a regular form or a subform?

Thanks very much for any help!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-08-05T03:09:03+00:00

Yeah, the fancy Nav form strikes again  ;-)

You need to go through the subform control:

  Forms!thenavigationform.thesubformcontrol.Form.cbo_Admin

Unless you've renamed them (or have more than one of them) try using the default names:

   Forms![Navigation Form].NavigationSubform.Form.cbo_Admin

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-08-06T16:09:03+00:00

    Using this new Navigation and the old Switchboard thingies cause just this kind of question to arise.  I avoid them just because, while they may be a convenience to beginners in some highly restricted scenarios, they often cause more trouble than they are worth over rhw long haul.

    There are ways to code things so the report is unaware of where/how it was opened (OpenArgs immediately comes to mind).  If I have a report that can be opened from several different places, I would definitely use OpenArgs.  Because it is a good practice to keep connections from one object to another to an absolute minimum, I use OpenArgs to pass information even if there is only one form structure (at the moment) involved.

    In youe case, the button's code might be:

       DoCmd.OpenReport "reportname",view, _

                    WhereCondition:= <criteria>, _

                    OpenArgs:= Me.cbo_Admin

    And the code in the report would look like:

       If Me.OpenArgs = "Criteria" Then ....

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-08-06T15:27:41+00:00

    So there is no way to code it to read both?  I have to hardcode whether I want to open through the subform or through the actual form?  If that is the case, I'm assuming that it would be best to build my own navigation form that would open the actual form rather than use subforms.

    Thanks for your help!

    Was this answer helpful?

    0 comments No comments