Solved

conditional formatting by expression; works different for subform?

Posted on 2004-08-19
4
406 Views
Last Modified: 2006-11-17
I have a subform with continuous records that I'm attempting to do some basic conditional formatting on, by EXPRESSION.

The subform has two textboxes, Description and Quantity (there are others, but these are the only ones that matter).  The subform is bound to a view that populate both these values.

I am trying to do conditional formatting on the Description textbox based on the value in the Quantity textbox.
I open the subform in design view (note, not the parent form, just the subform).
In the conditional formatting window, with "Expression Is" selected, I put in the following:

[Forms]![frmOrdersCropList]![tbxQuantity]=0

Switch to Form View and it looks perfect, the 0 items are formatted differently from the non-zero items.
But then when I open the main form in Form View with this subform built in,  I get no conditional formatting (as if none of the Quantities are 0).

So, the next thing I tried was to do the conditional formatting from Design View of the main form, and set the expression to
[Forms]![frmOrders]![frmOrdersCropList]![tbxQuantity]=0

This time when I switch to Form View, ALL the lines are formatted conditionally (as if ALL the Quantities are zero).
So, is there some trick to getting the conditional formatting to work for subforms?

Thanks.

0
Comment
Question by:rsoble
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
naivad earned 500 total points
ID: 11847285
try this...


[Forms]![frmOrders]![frmOrdersCropList].Form![tbxQuantity]=0


For future reference...open a new query, in the criteria box, right click, click build. Expand Forms, Expand the parent form, expand the child form, double click on the child control and it will auto build this string for you
0
 
LVL 4

Expert Comment

by:naivad
ID: 11847320
oops...make sure the form in question is in design view at the time and expand 'loaded forms' first.


Hope this helps.
0
 
LVL 1

Author Comment

by:rsoble
ID: 11847717
Thanks for the quick answer.   It worked great.
Umm... all the rest was kinda gobbledygook to me, but I appreciate it nonetheless :)
0
 
LVL 4

Expert Comment

by:naivad
ID: 11848197
No problem. I just wanted to show you how I was able to come up with the answer so you could figure this out the easy way next time.


When you build queries in the query designer, you can add tables and fields. When you add a field you can can specify a "WHERE" condition by putting something in the criteria field.

If you right click in this field, there is a "BUILD" option. This brings up the "Expression Builder".  The expression builder will build that string for you buy just drilling down to the object you are looking for. SubForms and SubReports are difficult to build these expressions for as you have found out.  If the parent form (the one containing the subform) is open, then it will be displayed in the "FORMS" container under the "Loaded Forms" container If a form containing a subform is in the LOADED FORMS container, then any subforms will be displayed under that form. Once the desired subform/subreport is selected, you can then click on any of the controls on that subform/report. If you double click on the control, it will build the entire expression for you and place it in the text area at the top of the "expression builder". I find this to be an invaluable tool.

This works with any DB object you are trying to find.

If my directions are too confusing...then open access help and type expression builder.

Good Luck!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question