Using wildcard characters in conditional formatting

G

Guest

Using AC2003 (2000 format)

I have a report based off of a query with the following seven fields:

PO Number, Description, Notes, Status, Date Entered, PO Created and Company

How would I make the bachgrounds of all seven fields red when the word
"material" shows up in the description field?

There could be text before and or after the word material in the field.
 
G

Guest

slowly learning said:
Using AC2003 (2000 format)

I have a report based off of a query with the following seven fields:

PO Number, Description, Notes, Status, Date Entered, PO Created and Company

How would I make the bachgrounds of all seven fields red when the word
"material" shows up in the description field?

There could be text before and or after the word material in the field.
I have solved this problem using example from fredg in "conditional
formatting on text string" if your looking for example of getting around
wildcard characters look there for solution
 
M

Marshall Barton

slowly said:
I have solved this problem using example from fredg in "conditional
formatting on text string" if your looking for example of getting around
wildcard characters look there for solution


I thought Fred also demonstrated how to use wildcards to do
that. Just use the expression:
[Description] Like "*material*"
 
G

Guest

Marshall Barton said:
slowly said:
I have solved this problem using example from fredg in "conditional
formatting on text string" if your looking for example of getting around
wildcard characters look there for solution


I thought Fred also demonstrated how to use wildcards to do
that. Just use the expression:
[Description] Like "*material*"
Using [Description] Like "*material*" would not work

Here is the code I ended up using based of of Fred's examples

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If InStr([Description], "Material") > 0 Or InStr([Description],
"Supplies") > 0 Then
[PO Number].BackColor = vbRed
[PO Number].ForeColor = 16777215
Description.BackColor = vbRed
Description.ForeColor = 16777215
Notes.BackColor = vbRed
Notes.ForeColor = 16777215
Status.BackColor = vbRed
Status.ForeColor = 16777215
[Date Entered].BackColor = vbRed
[Date Entered].ForeColor = 16777215
[PO Created].BackColor = vbRed
[PO Created].ForeColor = 16777215
Company.BackColor = vbRed
Company.ForeColor = 16777215

ElseIf Instr([PO Number], "1500") > 0 or Instr([PO NUmber], "1501") > 0
Then
[PO Number].BackColor = 16777215
[PO Number].ForeColor = vbRed
Description.BackColor = 16777215
Description.ForeColor = vbRed
Notes.BackColor = 16777215
Notes.ForeColor = vbRed
Status.BackColor = 16777215
Status.ForeColor = vbRed
[Date Entered].BackColor = 16777215
[Date Entered].ForeColor = vbRed
[PO Created].BackColor = 16777215
[PO Created].ForeColor = vbRed
Company.BackColor = 16777215
Company.ForeColor = vbRed

Else
[PO Number].BackColor = 16777215
[PO Number].ForeColor = vbBlack
Description.BackColor = 16777215
Description.ForeColor = vbBlack
Notes.BackColor = 16777215
Notes.ForeColor = vbBlack
Status.BackColor = 16777215
Status.ForeColor = vbBlack
[Date Entered].BackColor = 16777215
[Date Entered].ForeColor = vbBlack
[PO Created].BackColor = 16777215
[PO Created].ForeColor = vbBlack
Company.BackColor = 16777215
Company.ForeColor = vbBlack
End If

End Sub
 
M

Marshall Barton

slowly said:
Using [Description] Like "*material*" would not work

Here is the code I ended up using based of of Fred's examples

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If InStr([Description], "Material") > 0 Or InStr([Description],
"Supplies") > 0 Then
[snip non-pertinate code]


Unless I have been denied some critical, need to know
information ;-)

The expression:
InStr([Description], "Material") > 0
has the same result as:
[Description] Like "*Material*"
 
G

Guest

Marshall Barton said:
slowly said:
Using [Description] Like "*material*" would not work

Here is the code I ended up using based of of Fred's examples

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If InStr([Description], "Material") > 0 Or InStr([Description],
"Supplies") > 0 Then
[snip non-pertinate code]


Unless I have been denied some critical, need to know
information ;-)

The expression:
InStr([Description], "Material") > 0
has the same result as:
[Description] Like "*Material*"

If you look up "Highlight data by applying conditional formatting to a
control" in the access database help files it says:

"You cannot use wildcards— such as the asterisk (*), question mark (?), or
any other symbol— in criteria as substitutions for text or number characters."

My experience was that with the conditional formatting wizard I had no
results when trying to use the (*) as a wildcard; when using it in code it
highlighted all records in the report when only one or more met the condition
I was looking for.

The expression "InStr([Description], "Material") > 0" was a way around using
the (*) as a wildcard.

I don't claim by any means to be an expert in this area but the above
mentioned expression was the only way I could acheive the desired results I
was looking for.
 
M

Marshall Barton

slowly said:
Marshall Barton said:
slowly said:
Using [Description] Like "*material*" would not work

Here is the code I ended up using based of of Fred's examples

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If InStr([Description], "Material") > 0 Or InStr([Description],
"Supplies") > 0 Then
[snip non-pertinate code]


Unless I have been denied some critical, need to know
information ;-)

The expression:
InStr([Description], "Material") > 0
has the same result as:
[Description] Like "*Material*"

If you look up "Highlight data by applying conditional formatting to a
control" in the access database help files it says:

"You cannot use wildcards— such as the asterisk (*), question mark (?), or
any other symbol— in criteria as substitutions for text or number characters."

My experience was that with the conditional formatting wizard I had no
results when trying to use the (*) as a wildcard; when using it in code it
highlighted all records in the report when only one or more met the condition
I was looking for.

The expression "InStr([Description], "Material") > 0" was a way around using
the (*) as a wildcard.

I don't claim by any means to be an expert in this area but the above
mentioned expression was the only way I could acheive the desired results I
was looking for.


I guess I lost track of the CF part of the question. Your
code doesn't use CF so I thought the latest issue was about
using Like in your code. I can't see how Instr vs Like can
make a difference in the posted code. If it does, I would
like to understand how.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top