Checkbox event help

agrogers15

New Member
Joined
Sep 9, 2016
Messages
10
I am using the status of a checkbox to change the color of a rectangular box behind a field for quick status reference.
Code:
Private Sub Permit_Received_Click()
If Me.Permit_Received = Yes Then
Me.PermitHighlight.BackColor = vbRed
Else
Me.PermitHighlight.BackColor = vbGreen
End If
End Sub
First thing I notice that I don't understand, is the color changes opposite of how I think. I originally had the colors in the opposite spot so that when I check the box it turns green but it was opposite. I then changed the initial If statement to No but it still did the same thing. So I changed the color syntax locations and it worked, but it doesn't stay in the proper back color. When I close the form and reopen it defaults back to red. How do I keep the backcolor while the checkbox is checked?
 
Recap of where I am at. MS ACCESS 2007

I am using a split form as my main form. I have a tabbed subform that contain a checklist tab with 4 check boxes. Currently, when I check a box, it fires an ******* event of the checkbox to update the color of a textbox physically behind the checkbox on the form. I also now have an on current even linked to the subform that will keep the color current. Now on my main form that is a split form in the datasheet section next to each record there is a small box with a + sign in it. When I click the + box it expands the records to display the data from my subforms. The data displayed from my subform on my mainform will not update until I expand the record and enter the subform data in the datasheet section.

What I now need is to have the subform data update on my mainform without having to expand the record.

Let me know if I need to post pictures of what is happening and I will.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
ext to each record there is a small box with a + sign in it
That has to be a lookup. Presumably defined at the table level.

If you have some data in the subform *and* the main form then I guess you need an on current event in both forms (generally, you want data displayed in only one place, either on a subform or on a main form, but not both - "parent" records on the main form and "child" records on the subform). Or possibly the on current event you have in the subform can also hit the main form if you write code to handle that. Remember that each form has its own current event - so the subform current event is independent of the main form current event.
 
Last edited:
Upvote 0
Just occurred to me that the + sign is the table view that you see when relationships are defined. It expands to show related records and doesn't depend on the existence of a subform.

For a split form, a current event on the form works on the detail section and not the header. While it appears to be a sub form, there actually isn't one.
 
Upvote 0
So I ended up just redoing the layout. I put everything on the mainform and I am using a combobox to input data into the field. I then am using conditional formatting to highlight the field based on the values and is working much more efficiently. I do now have one last question. I have a few fields where I need the conditional formatting to go away when a checkbox is cleared. Anyone know how to do that?
 
Upvote 0
Hi, why wouldn't it be basically the same as adding the conditional formatting (except now taking it away)?
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top