C
CSDunn
Hello,
I have an Access 2000 ADP report that contains a number of bound text boxes.
The report shows student report card marks. If the value of any text box
contains an 'X', then the BackColor of the textbox is shaded black.
Otherwise, the value of the textbox appears.
The following code is used in the OnFormat event of the report header:
Private Sub FormHeader_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Value = "X" Then
ctl.BackColor = 0
Else
ctl.BackColor = ctl.Tag
End If
End If
Next ctl
End Sub
This works fine until a user tries to view a report card for a student where
no report card data has been input. When a user tries to preview such a
report, the following error message appears when the user clicks a button
from a form to preview the report:
****************************
Run-time error "2427";
You entered an expression that has no value.
****************************
When I debug, the error points to line six of the above code;
'If ctl.Value = "X" Then'
I suppose that this message is being generated becasue there is no data for
the report. How can I handle this error so that the user can receive a
friendly message like, "There is no report card data for this student."?
Thanks for your help!
CSDunn
I have an Access 2000 ADP report that contains a number of bound text boxes.
The report shows student report card marks. If the value of any text box
contains an 'X', then the BackColor of the textbox is shaded black.
Otherwise, the value of the textbox appears.
The following code is used in the OnFormat event of the report header:
Private Sub FormHeader_Format(Cancel As Integer, FormatCount As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
If ctl.Value = "X" Then
ctl.BackColor = 0
Else
ctl.BackColor = ctl.Tag
End If
End If
Next ctl
End Sub
This works fine until a user tries to view a report card for a student where
no report card data has been input. When a user tries to preview such a
report, the following error message appears when the user clicks a button
from a form to preview the report:
****************************
Run-time error "2427";
You entered an expression that has no value.
****************************
When I debug, the error points to line six of the above code;
'If ctl.Value = "X" Then'
I suppose that this message is being generated becasue there is no data for
the report. How can I handle this error so that the user can receive a
friendly message like, "There is no report card data for this student."?
Thanks for your help!
CSDunn