|
Prev: String manipulation
Next: Why doesn't this code work?
From: J Lagos on 6 Jul 2008 01:46 I want to change the backcolor of textboxes in a report depending on their value. I messed with this for a few hours but I'm not savvy with the syntax for getting at controls in a report. can anyone suggest a direction. For example the Textboxes would contain values like "8R", "8S", "10S", the numbers would change depending on user input, but the letters are restricted to about 8 different letters that mean different things. I want to change the color based on the letter value.
From: Tom van Stiphout on 6 Jul 2008 12:46 On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <rushrules__(a)shaw.ca> wrote: Use Conditional Formatting. And make sure the BackStyle of your control is not Transparent. -Tom. >I want to change the backcolor of textboxes in a report depending on their >value. >I messed with this for a few hours but I'm not savvy with the syntax for >getting at controls in a report. > >can anyone suggest a direction. > >For example the Textboxes would contain values like "8R", "8S", "10S", > >the numbers would change depending on user input, but the letters are >restricted to about 8 different letters that mean different things. I want >to change the color based on the letter value.
From: J Lagos on 6 Jul 2008 13:00 I need more options than conditional formatting provides so I gave this a go...and it still doesn't work Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Dim ctl As Control Dim strV For Each ctl In Me.Section(0).Controls With ctl If .Tag = "W" Then strV = Right(ctl, 1) Debug.Print ctl.Name Debug.Print strV Select Case strV Case "R" .BackColor = RGB(255, 224, 244) 'pale red Case "L" .BackColor = vbYellow Case Else .BackColor = vbRed End Select End If End With Next ctl End Sub "Tom van Stiphout" <no.spam.tom7744(a)cox.net> wrote in message news:6lt1749j7k2tvmodh031bgbnu8tfejf5gu(a)4ax.com... > On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <rushrules__(a)shaw.ca> > wrote: > > Use Conditional Formatting. And make sure the BackStyle of your > control is not Transparent. > > -Tom. > > >>I want to change the backcolor of textboxes in a report depending on their >>value. >>I messed with this for a few hours but I'm not savvy with the syntax for >>getting at controls in a report. >> >>can anyone suggest a direction. >> >>For example the Textboxes would contain values like "8R", "8S", "10S", >> >>the numbers would change depending on user input, but the letters are >>restricted to about 8 different letters that mean different things. I want >>to change the color based on the letter value.
From: Tom van Stiphout on 6 Jul 2008 13:55 On Sun, 06 Jul 2008 17:00:39 GMT, "J Lagos" <rushrules__(a)shaw.ca> wrote: I pasted your code in a report in the Northwind sample database and it worked. One gotcha I just learned about: you have to open your report in code (NOT switch from design view to preview) for the Detail_Format event to occur: For example in the immediate window enter: DoCmd.OpenReport "myReport", acViewPreview -Tom. >I need more options than conditional formatting provides so I gave this a >go...and it still doesn't work > >Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) >Dim ctl As Control >Dim strV > > > For Each ctl In Me.Section(0).Controls >With ctl >If .Tag = "W" Then > strV = Right(ctl, 1) > Debug.Print ctl.Name > Debug.Print strV > Select Case strV > Case "R" > .BackColor = RGB(255, 224, 244) 'pale red > Case "L" > .BackColor = vbYellow > Case Else > .BackColor = vbRed > End Select > End If > End With >Next ctl > > >End Sub >"Tom van Stiphout" <no.spam.tom7744(a)cox.net> wrote in message >news:6lt1749j7k2tvmodh031bgbnu8tfejf5gu(a)4ax.com... >> On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <rushrules__(a)shaw.ca> >> wrote: >> >> Use Conditional Formatting. And make sure the BackStyle of your >> control is not Transparent. >> >> -Tom. >> >> >>>I want to change the backcolor of textboxes in a report depending on their >>>value. >>>I messed with this for a few hours but I'm not savvy with the syntax for >>>getting at controls in a report. >>> >>>can anyone suggest a direction. >>> >>>For example the Textboxes would contain values like "8R", "8S", "10S", >>> >>>the numbers would change depending on user input, but the letters are >>>restricted to about 8 different letters that mean different things. I want >>>to change the color based on the letter value.
From: J Lagos on 6 Jul 2008 15:12 The issue is my fault. I had the conditional formatting set in the textboxes...your reference to conditional formatting clued me in, and I checked it and removed the conditional formatting and the code ran fine. "Tom van Stiphout" <no.spam.tom7744(a)cox.net> wrote in message news:oj127413e1rrt7kbqdfue1aiaqe92v2bsl(a)4ax.com... > On Sun, 06 Jul 2008 17:00:39 GMT, "J Lagos" <rushrules__(a)shaw.ca> > wrote: > > I pasted your code in a report in the Northwind sample database and it > worked. One gotcha I just learned about: you have to open your report > in code (NOT switch from design view to preview) for the Detail_Format > event to occur: > For example in the immediate window enter: > DoCmd.OpenReport "myReport", acViewPreview > > -Tom. > > >>I need more options than conditional formatting provides so I gave this a >>go...and it still doesn't work >> >>Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) >>Dim ctl As Control >>Dim strV >> >> >> For Each ctl In Me.Section(0).Controls >>With ctl >>If .Tag = "W" Then >> strV = Right(ctl, 1) >> Debug.Print ctl.Name >> Debug.Print strV >> Select Case strV >> Case "R" >> .BackColor = RGB(255, 224, 244) 'pale red >> Case "L" >> .BackColor = vbYellow >> Case Else >> .BackColor = vbRed >> End Select >> End If >> End With >>Next ctl >> >> >>End Sub >>"Tom van Stiphout" <no.spam.tom7744(a)cox.net> wrote in message >>news:6lt1749j7k2tvmodh031bgbnu8tfejf5gu(a)4ax.com... >>> On Sun, 06 Jul 2008 05:46:04 GMT, "J Lagos" <rushrules__(a)shaw.ca> >>> wrote: >>> >>> Use Conditional Formatting. And make sure the BackStyle of your >>> control is not Transparent. >>> >>> -Tom. >>> >>> >>>>I want to change the backcolor of textboxes in a report depending on >>>>their >>>>value. >>>>I messed with this for a few hours but I'm not savvy with the syntax for >>>>getting at controls in a report. >>>> >>>>can anyone suggest a direction. >>>> >>>>For example the Textboxes would contain values like "8R", "8S", "10S", >>>> >>>>the numbers would change depending on user input, but the letters are >>>>restricted to about 8 different letters that mean different things. I >>>>want >>>>to change the color based on the letter value.
|
Pages: 1 Prev: String manipulation Next: Why doesn't this code work? |