Error Running Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am recieving the following error when executing the following code in a
report:

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

Function ChangeColor(strErrCall As String)
On Error GoTo Err_ChangeColor
Select Case Me.chkPending
Case 0
Me.Project_Number.ForeColor = -2147483643
Me.Financial_Strip.ForeColor = -2147483643
Me.Notes.ForeColor = -2147483643
Case -1
Me.Project_Number.ForeColor = 16191485
Me.Financial_Strip.ForeColor = 16191485
Me.Notes.ForeColor = 16191485
End Select
Exit_ChangeColor:
Exit Function
Err_ChangeBGColor:
MsgBox Err.Description & strErrCall
Resume Exit_ChangeBGColor
End Function

Private Sub Report_Open(Cancel As Integer)
ChangeBGColor (" - Called from Report_Open.")
End Sub

I do not get this error if i execute the same code on a form. If i try
"MsgBox Me.chkPending" i get the same error. I am trying to get the value of
a check box. Thank you for any help.
 
I am recieving the following error when executing the following code
in a report:

Remove the On Error line and find out which line is failing. I cannot
imagine what the error handling in this code is meant to achieve anyway.

B Wishes


Tim F
 
It is failing on Me.chkPending stating that "You entered an expression that
has no value." Me.chkPending is a checkbox in the report. Thanks for the help.
 
It is failing on Me.chkPending stating that "You entered an expression
that has no value." Me.chkPending is a checkbox in the report.

If it's control, then you need to address the controls collection. Try

Me.Controls("chkPending")

or, for short

Me!chkPending

Access only exposes fields in the recordsource as properties (i.e. visible
with the dot operator), not controls.

Hope that helps


Tim F
 
If you are calling this from the report's open event, then I believe that the
control is not populated yet and is probably not available. Perhaps you can get
the value you need some other way - using a DLookup function for example.

Also, I think you really need to call the function without the () as in
ChangeBGColor " - Called from Report_Open."
 
Back
Top