none
Refer to report detail section textboxes in VBA RRS feed

  • Question

  • Using Access 2003 VBA, I have a report using some 57 bound and calculated fields.

    Client wants any field that is not equal to Zero to print in red.

    In the Detail On Print event of the report, I need to loop through the textbox controls of the the Detail Section.

    How do I refer to this report's Detail Section textboxes?

    Current code below changes all txtboxes to red (as far as I could get)
    Dim db As DAO.Database
    Dim ctl As Control
    Dim fld As DAO.Field
    Dim prp As Property

    Set db = CurrentDb()
    For Each ctl In Me.Detail.Controls
        
        With ctl
            Select Case .ControlType
                Case acTextBox
                    .ForeColor = vbRed
                    End Select
        End With

    Next

    Thanks for any help,

    Robert

    Tuesday, June 12, 2012 3:47 PM

All replies

  • Try

        With ctl
            Select Case .ControlType
                Case acTextBox
                    If .Value <> 0 Then
                        .ForeColor = vbRed
                    Else
                        .ForeColor = vbBlack
                    End If
            End Select
        End With


    Regards, Hans Vogelaar

    Thursday, June 14, 2012 2:05 PM