Change the background colour to red if the (word) or (words) are surrounded by a Bracket (2 Viewers)

access2010

Registered User.
Local time
Today, 03:44
Joined
Dec 26, 2009
Messages
1,172
I can control the background colour for a single word in MsAccess 2003, but have not been able to find out how to control the background colour if the word or words are contained (within) Brackets..
I have tried

Operator: Expression Is
Condition: Like "*(*)*"(*)

This looks for any text within parentheses and produces an error.
Your assistance would be appreciated.

Thank you Frida
 

Attachments

Are you looking for more than one set of brackets? Have you tried?

Code:
Like “*(*)*”

PS. Typing from phone, not sure why it created a smart quote. Make sure to type the above code into your project manually, don’t copy and paste.
 
Parentheses are: ( )
Brackets are: [ ]
Braces are: { }

Maybe just look for opening parenthesis: InStr([Advice], "(") > 0
 
Are you looking for more than one set of brackets? Have you tried?

Code:
Like “*(*)*”

PS. Typing from phone, not sure why it created a smart quote. Make sure to type the above code into your project manually, don’t copy and paste.
Thank you TheDBguy for your suggestion, which we did try, but receive the following error message.
 

Attachments

Parentheses are: ( )
Brackets are: [ ]
Braces are: { }

Maybe just look for opening parenthesis: InStr([Advice], "(") > 0
Thank you June7 for your suggestion, which we did try, but receive the following error message.
 

Attachments

If the complete contents of the control are enclosed in parentheses, as in your posted examples, try the following expression:

Code:
Left([FullName],1)="(" And Right([FullName],1)=")"
 
Your attempt does not do what I suggested. Expression is: InStr([Advice], "(") > 0
 
If the complete contents of the control are enclosed in parentheses, as in your posted examples, try the following expression:

Code:
Left([FullName],1)="(" And Right([FullName],1)=")"
Thank you Ken for your suggestion.

My problem as pointed out by June7, was that I was using the wrong brackets.
 
Expression is: InStr([Advice], "(") > 0
That will return True if the string expression contains a leading parenthesis anywhere in the string, so assumes this will be matched by a closing parenthesis. If the Instr function is to be used, a more robust expression, which will only return True if there are correctly positioned opening and closing parentheses would be:

Code:
Instr(FullName,"(")>0 And InstrRev(FullName,")")>Instr(FullName,"(")

Pattern matching with the Like operator is a better solution, however, as the OP has now realised.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom