See the pictureThanks.
Ok I clicked the combo box on the bottom where the datasheet section is for design view and went to conditional formatting and selected a new rule. I then selected "Expression Is" and pasted this into the field next to it:
If Left ([cmbSplitUserSecurity],1) In ("2","3")
I get an error message saying "The expression you entered contains invalid syntax. You may have entered an operand without an operator."
So then I did the same thing for one of the text boxes that I wanted to be bold, if the combo box contained a certain value (3 ADMIN) and I get the same error message.
Do I need to add something else to the expression? How does it know to make the other text boxes bold?
Thanks Gicu.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba
Upon further examination, what I posted was not correct. You would have seen what that was in the email that the forum sent.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
@data808: have you managed to get it going? If not can you please show us what you have in the conditional formatting and any errors that you are still getting?
Make sure the combo's bound column (not the first visible one) returns the values you think it does.
Cheers,
Thanks Gicu. Sorry for the delay. I couldn't get it to work. Right now I just have a conditional formatting to color code the actual combo box which basically has 5 different values to choose from in the drop down list. So based on what value is selected will determine what color to highlight and make bold in the combo box for the data sheet section of the split form.
What I actually want is, based on the value selected for the combo box, make another field which is the user's name to be highlighted in a specific color and bold instead of the combo box itself. Basically the combo box shows the user security level such as clerk, supervisor, or admin for example. So if the record has "supervisor" selected for the combo box value then make that user's name field be highlighted yellow and bold. If the combo box is admin, then make the user's name field be red and bold.
It's just a way to draw attention to users with special permissions. Is this possible to do?
Thanks.
It should be possible with conditional formatting as you can reference another field in the record in the expressions for formatting, what have you tried?
Cheers,
Based on the picture provided by Welshgasman in Post #17 here is what I tried so far:
I did conditional formatting on both the combo box and the employee fields using "Expression Is".
The expressions I've tested is this:
Left([cmbSplitUserSecurity],5) In ("txtSplitEmpName","3 ADMIN")
Left([txtSplitEmpName],5) In ("cmbSplitUserSecurity","3 ADMIN")
with no luck. Nothing happens. For testing I just set it to bold for these expressions with no highlighting for now. Just wanted to see if it would work. So not sure if I am reading it wrong but the original expression example that Welshgasman provided in the photo was this:
Left([Field2],5) In ("Field","Test")
The "Fields" in this expression made me think that, that is where the name of the combo box and employee name field needs to go and the "Test" was the value of the combo box. Is that not correct?
if txtSplitEmpName is the name of a control, it needs to be in square brackets.Code:Left([cmbSplitUserSecurity],5) In ("txtSplitEmpName","3 ADMIN")
If it is not, the how do you expect a 3 character value to equal a string which is a different length?
you are using the first 5 characters of cmbSplitUserSecurity, so you can only have 5 characters for the 'in' part
Left([cmbSplitUserSecurity],5) In ("txtSp","3 ADM")
In post #8 I gave you an expression to try, have you tried that?
Left ([cmbSplitUserSecurity],1) In ("2","3")
Cheers,
Yeah tried that and I get invalid syntax error that says:
The expression you entered contains invalid syntax. You may have entered an operand without an operator.
Also I'm not sure if this conditional formatting needs to be with the txtSplitEmpName or the cmbSplitUserSecurity.
Update: I just tried it again and it worked! I remember trying it back when you first suggested it in post #8 and got that same syntax error so I gave up on it cause I wasn't sure if I was using it correctly. So when I tried it again just now to give you an explanation of what happens, it gave that same syntax error but after I wrote that I'm not sure if the conditional formatting needs to be with the employee field or the combo box in this post, I went and tried it one more time on the employee field and it worked. So not sure what I was doing wrong for it to cause the syntax error but its working fine now.
Thanks Gicu for all your expertise! Appreciate it.
That sort of expression has to equate to something; i.e. you must assign the value it returns to something, be that a variable, object or perhaps (although maybe not in this case) a property. You probably fixed it by assigning the return value of left function to an unbound control (thus its default property, which is .Value) or a bound control (thus the field (object) it is bound to).
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Glad to hear you got it going, can't remember how many times I tried things and weren't working and then ..bingo, it worked....
@Micron: the expression was to be used in the conditional formatting wizard in the text box(es) (txtSplitEmpName and I think others) to be formatted based on the values in another field (the combo named cmbSplitUserSecurity).
Cheers,
I realized the two suggestions you offered were slightly different. In post #8 you gave this:Glad to hear you got it going, can't remember how many times I tried things and weren't working and then ..bingo, it worked....
@Micron: the expression was to be used in the conditional formatting wizard in the text box(es) (txtSplitEmpName and I think others) to be formatted based on the values in another field (the combo named cmbSplitUserSecurity).
Cheers,
If Left ([cboYourCombo],1) In ("2","3")
Then in post #24 you gave this:
Left ([cmbSplitUserSecurity],1) In ("2","3")
So maybe the "If" is what caused the syntax error since post #24 is the one that worked. Just my guess though. Thanks again @Gicu.