Solved

Conditional formatting Datasheet subform

Posted on 2009-06-29
12
361 Views
Last Modified: 2013-11-28
How do I set the conditional formatting of a field where it looks at the value of another field and using a wild card determine if the value of the current field is contained within the value of the 2nd field?

I tried to set the conditional formatting to using the Expression not equal to Like "* fieldName1 *" or Like "*& fieldName1 & *"  I even tried to use a variable function that sets the value of Field2 within the Like statement without success.  

what is the proper syntax?
0
Comment
Question by:Karen Schaefer
  • 6
  • 4
  • 2
12 Comments
 
LVL 5

Expert Comment

by:DBDevl
ID: 24738362
Try:

Like "*" & fieldName1 & "*"

or

Like "*'" & fieldName1 & "'*"
0
 

Author Comment

by:Karen Schaefer
ID: 24738449
sorry neither way works - getting a syntax error.  see attached.co
ConditionalFormatPic.jpg
0
 
LVL 5

Expert Comment

by:DBDevl
ID: 24738647
Try this:

In the Condition 1 drop down select Expression Is, then enter this, InStr([field1].Value,[field2].value)>0
0
 
LVL 5

Expert Comment

by:DBDevl
ID: 24738689
Put a 1 as the last parameter to make the search not case sensitive:

InStr([field1].Value,[field2].value, 1)>0
0
 
LVL 5

Expert Comment

by:DBDevl
ID: 24738716
Here is a complete description, it seems it may work for what you are trying to do.

InStr([start,] string1, string2 [, compare])

The InStr function syntax has these parts:

start Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. The start argument is required if compare is specified.

string1 Required. String expression being searched.

string2 Required. String expression sought.

compare Optional; numeric. A value of 0 (the default) specifies a binary (case-sensitive) search. A value of 1 specifies a textual (case-insensitive) search.
0
 

Author Comment

by:Karen Schaefer
ID: 24738902
sorry a little confused - When I use the InStr([Eqpt_Loc_N0].Value,[txtApNO].Value)>0, doesn't this mean if the 2 fields = each other than change the format.

I need to check if not equal to each other and also some other criteria exists.

1.  where Eqpt_Loc_N0<> txtapno
2.  Where Eqpt_Loc_N0] <> LIKE "*LH*' OR LIKE "*LAB*"

So what is the proper syntax to handle the various options?

Thanks
k
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 5

Expert Comment

by:DBDevl
ID: 24739112
This should return true if txtApNo, LH, LAB are not in Eqpt_Loc_No, but I haven't tested it.

(InStr([Eqpt_Loc_N0].Value,[txtApNO].Value,1)=0) And (InStr([Eqpt_Loc_N0].Value"LH",1)=0) And (InStr([Eqpt_Loc_N0].Value,"LAB",1)=0)
0
 
LVL 5

Expert Comment

by:DBDevl
ID: 24739144
So, conversely, if any of those values are in Eqpt_Loc_No it will return false.
0
 

Author Comment

by:Karen Schaefer
ID: 24739154
thanks for the assist, however problem with syntax.

K
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24743659
kfschaefer1,

A sample would go a long way to avoiding any abiguity...

For eaxmple instead of saying:
" formatting of a field where it looks at the value of another field"
Huh?

You instead say:
I have a LastName Field on the subform, If the first 3 characters of the Last Name on the subform matches with the first 3 characters of the LastName on the Main form then make the Country Field on the subform Red.

c'mon k, how long have you known me....

;-)

Here is a sample, ...in "Real words" here is what it does.
It formats the ShipCountry in the Subform to Red if the Main form's CompanyName contains "er"  (Like "*er*")

I am sure you can take this sample and, on your own, easily adapt it for almost any combination of conditions you need.

Jeff
Access-EEQConditionallyFormatDat.mdb
0
 

Author Closing Comment

by:Karen Schaefer
ID: 31598041
Thanks Jeff, for your input as always you are a great help.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24747056
I'm trying to get you to "then next Level"

;-)

Jeff
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

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

19 Experts available now in Live!

Get 1:1 Help Now