Solved

Conditional formatting Datasheet subform

Posted on 2009-06-29
12
367 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

914 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

13 Experts available now in Live!

Get 1:1 Help Now