Full Version: Datasheet: highlight rows if box checked
UtterAccess Forums > Microsoft® Access > Access Forms
Mishka1
Hi, I have a bunch of records in datasheet view that represent a worker's queue. When they click the checkbox, I want the row to be highlighted so they can keep track of where they are. I am using this code on the On Click event of the checkbox but it doesn't work. Any suggestions? It needs to be in datasheet view.
CODE
Private Sub CheckboxAction_Click()
    If CheckboxAction = -1 Then
    
        Me.CASE_ID.BackColor = 13434828
        Me.AMT_CURR.BackColor = 13434828
        Me.DESC_LINE_1.BackColor = 13434828
        Me.DESC_LINE_2.BackColor = 13434828
        Me.DESCRIPTION.BackColor = 13434828
    End If
End Sub
AQM_UK
I do not think you can do this in datasheet mode.
You can use conditional formatting on a continuous form, and by the way you format this form, you can make it look like a datasheet.
This is also better as you can include other buttons on your continuous form, which are not possible of a datasheet view.
Jim
Mishka1
That is the news I was afraid of getting but I'm glad I now know for sure. Thanks for responding so quickly.
AQM_UK
Just to say, the checkbox has to be bound to the form and not unbound. If it is unbound, you will highlight everything.
Just to reitterate, it is not the end of the world, as the continuous IMCO is the better way to go.
Jim
Mishka1
Great follow up! I am finding that out right now.
Mishka1
Even though the checkbox is bound it is still highlighting everything.
and by bound you do mean that the checkbox is found on the table per each record and that is what is included on the form?)
Any more reasons why they would all get highlighted?
(to add to my code above, there is a 'me.' before the 'CheckboxAction')
AQM_UK
I did mean that it was bound to the talble, yes.
Have you looked at conditional formatting?
Jim
Mishka1
I do not have any conditional formatting going on.
If you mean, have I tried using it to get the effect I needed, I tried, but I don't know how to make my expression to check if the "CheckboxAction" is "-1" since the expression is looking to see what it equals. Any suggestions there?
AQM_UK
Yes
et back in a bit
Mishka1
Ha! I found something that worked here . Thanks for your help.
JVanKirk
Without using some different code, you won't be able to highlight just the checked rows in your contiuous forms, however, as Jim eluded to, using the conditional formatting will. You have to set the conditional formatting on each of the controls in the row..OR..add a box behind all the controls, make it your form background color by default and then change it to the highlighted color based on the check box. I think if you select the Expression Is option and then put this in the window next to it you should be good to go or close:
orms!YourFormName.CheckboxAction = -1
Then select the color options you want for your box or each individual control.
J
AQM_UK
Thanks Jason.
ishka, soory i could not respond last night, i was just popping out for a Ruby (Ruby = Ruby Murry = Curry) with the wife so did not get chance.
If you found something that works, that is great.
HAs Jason eluded and what i was going to post, if you set the conditional format in each control with a expressions to say
[CheckboxAction]=-1
The set the background to change and you can change font and you can change style etc etc.
So you do this for all your controls in the continuous form, and then, when they click the checkbox, the controls change.
However, if you are there now, you are okay.
Jim
Mishka1
Thanks guys. It's looking great now.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.