print pass instead of P access report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    print pass instead of P access report

    hi
    I am using XP operating system and access 2007
    Ours is a table which contains a field result with data A, P and F. I want to print report based on it.
    I want to print pass instead of P and fail instead of F and so on. I made the report based on it. I know that it can be achieved through VBA .I selected the result field in report design mode on view code I write the code but I am really unable to achieve the target it still print A,P and so on in layout view.
    Code:
    Private Sub RESULT_BeforeUpdate(Cancel As Integer)
    If (RESULT.Value = "A") Then
    RESULT.Value = "ABSENT"
    RESULT.Text = "ABSENT"
    End If
    End Sub
    I am very new to this subject kindly help
    Thanks in advance
    Last edited by kkshansid; Apr 27 '12, 09:45 AM. Reason: grammer
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32634

    #2
    This would need to be done in an After_Update() event procedure. Before_Update() will not allow you to change the control's value.
    Code:
    Private Sub RESULT_AfterUpdate()
        with Me
            Select Case .RESULT
            Case "A"
                .RESULT = "Absent"
            Case "F"
                .RESULT = "Fail"
            Case "P"
                .RESULT = "Pass"
        End With
    End Sub

    Comment

    • Mihail
      Contributor
      • Apr 2011
      • 759

      #3
      Or, in the report:
      Design a new text box and set it's control source as:
      Code:
      =IIF([FiledName]="P","Pass",IIF([FiledName]="F","Fail","Absent"))
      Hide the old one (I am not sure but, maybe, you can remove it)

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32634

        #4
        Agreed. I was misled by the existing code which appears to be 100% inappropriate within the confines of this question.

        Comment

        Working...