Here is what I'm working with
Form = MAINfrm (Single Form)
Subform on MAINfrm = MAINsub (Single Form)
Subform on MAINsub = INVsub (Continuous Form)
Fields on INVsub = ITEMIDbox, ITEMNAMEbox, ITEMSTATUSbox
I also have a Rectangle on the form called BGbox
Options for ITEMSTATUSbox = Active, Inactive, Sold, Archived
I want to change the color of the BGbox.backcolor based on the value in ITEMSTATUSbox.value
Here is my code:
Results of this code seem to work except for the changing the backcolor part. The subform loads correctly and the recordsets are cycled thru, but no color change.... and my debug.print reflects the correct changes I would expect to see. But visually no change. I checked the BGbox rectangle and it is visible with a current backcolor set to Background 1 and back style set to Normal.
[highlight #8AE234][EDITED][/highlight] Oh and the code is on the STOPbox_Afterupdate() Event from the form: Forms!MAINfrm!MAINsub. Basically the user chooses a value from this dropdown... that value is a criteria for the Rowsource on the Continuous Form: Forms!MAINfrm!MAINsub!INVsub [highlight #8AE234][EDITED][/highlight]
I Searched for an easier way and couldn't find anything but a zip file with an example of how to do it written by Steven Lebans, but unfortunately when I tried to open it, it said it was written in a prior version of Access and I couldn't open it. I'm using Office 365. Every other post I found basically said it couldn't be done except on Current but only for one detail at a time, but not looping thru. I tried on Current for the subform and Access froze.
Form = MAINfrm (Single Form)
Subform on MAINfrm = MAINsub (Single Form)
Subform on MAINsub = INVsub (Continuous Form)
Fields on INVsub = ITEMIDbox, ITEMNAMEbox, ITEMSTATUSbox
I also have a Rectangle on the form called BGbox
Options for ITEMSTATUSbox = Active, Inactive, Sold, Archived
I want to change the color of the BGbox.backcolor based on the value in ITEMSTATUSbox.value
Here is my code:
Code:
Forms!MAINfrm!MAINsub!INVsub.SourceObject = "INVsub"
Forms!MAINfrm!MAINsub!INVsub.Requery
Dim rstSubForm As Recordset
Set rstSubForm = Forms!MAINfrm!MAINsub!INVsub.Form.Recordset
rstSubForm.MoveFirst
Do While Not rstSubForm.EOF
Select Case Forms!MAINfrm!MAINsub!INVsub!ITEMSTATUSbox.Value
Case "Inactive"
Forms!MAINfrm!MAINsub!INVsub!BGbox.BackColor = "16777215"
Case "Active"
Forms!MAINfrm!MAINsub!INVsub!BGbox.BackColor = "13434879"
Case "Sold"
Forms!MAINfrm!MAINsub!INVsub!BGbox.BackColor = "13434828"
Case "Archived"
Forms!MAINfrm!MAINsub!INVsub!BGbox.BackColor = "16772300"
End Select
Debug.Print Forms!MAINfrm!MAINsub!INVsub!BGbox.BackColor
rstSubForm.MoveNext
Loop
rstSubForm.MoveFirst
Results of this code seem to work except for the changing the backcolor part. The subform loads correctly and the recordsets are cycled thru, but no color change.... and my debug.print reflects the correct changes I would expect to see. But visually no change. I checked the BGbox rectangle and it is visible with a current backcolor set to Background 1 and back style set to Normal.
[highlight #8AE234][EDITED][/highlight] Oh and the code is on the STOPbox_Afterupdate() Event from the form: Forms!MAINfrm!MAINsub. Basically the user chooses a value from this dropdown... that value is a criteria for the Rowsource on the Continuous Form: Forms!MAINfrm!MAINsub!INVsub [highlight #8AE234][EDITED][/highlight]
I Searched for an easier way and couldn't find anything but a zip file with an example of how to do it written by Steven Lebans, but unfortunately when I tried to open it, it said it was written in a prior version of Access and I couldn't open it. I'm using Office 365. Every other post I found basically said it couldn't be done except on Current but only for one detail at a time, but not looping thru. I tried on Current for the subform and Access froze.