Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

conditional formatting by expression; works different for subform?

Posted on 2004-08-19
4
Medium Priority
?
412 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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 …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

824 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