Solved

conditional formatting by expression; works different for subform?

Posted on 2004-08-19
4
403 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 Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now