Run time error 2427 - You entered an expression that has no value

I have a report in Access 2003 where I want the back color of a text box to change based on the value in another text box.  The code I'm using is shown below.

Option Compare Database
Option Explicit
Private Sub Report_Open(Cancel As Integer)
    If Me.txtQuartileCurrent.Value = 1 Then
       Me.TxtCurrentMonthRanking.BackColor = 16711680
    End If
End Sub

The field that populates txtQuartileCurrent has no nulls and I will expand the code to include values of 2, 3, and 4 when this error has been eliminated.

I compacted the file but no change in results.  Any suggestions would be appreciated.
Liberty4allAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
You should probably not use the OnOpen event but the OnFormat or OnPrint event.

/gustav
0
Liberty4allAuthor Commented:
Both OnFormat and OnPrint succeed in elminating the error but neither produce a colored background (BackColor = 16711680)

I tried adding this line to change the back color:
Me.TxtCurrentMonthRanking.BackStyle = 1
but this changed the back color in all txtCurrentMonthRanking boxes, not just those that meet the specified criteria.  The default property for back style is transparent.

Can you suggest what I should try next?
0
Gustav BrockCIOCommented:
It sounds like you use the events of the report, not those of the Detail section.

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Liberty4allAuthor Commented:
You are correct - I was using the events of the report.  The On Format property of the detail section works well.  I also forgot to change the Back Style property of the text box from transparent to normal.  This is needed to make the colors appear.  It's also necessary to add all the code to make the end result appear as desired.  The complete code for one text box is shown below.

If Me.txtQuartileCurrent.Value = 1 Then
       Me.TxtCurrentMonthRanking.BackColor = 16777088
    End If
   
    If Me.txtQuartileCurrent.Value = 2 Then
       Me.TxtCurrentMonthRanking.BackColor = 65408
    End If
   
    If Me.txtQuartileCurrent.Value = 3 Then
       Me.TxtCurrentMonthRanking.BackColor = 65535
    End If
   
    If Me.txtQuartileCurrent.Value = 4 Then
       Me.TxtCurrentMonthRanking.BackColor = 8421631
    End If

I appreciate your help and quick response on this.
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.