Results 1 to 13 of 13
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Changing a text field output for a report.

    I have a field of which I want to reference in a report, but if another field = true then I would want to change the output to a different name.

    Field 1..........Field 2.........Output
    Approve........False...........Approve
    Approve........True...........Approved

    I was thinking you could make the field unbound and go that route and do it on an unbound field. I'm still figuring out the color codes. if you have a reference for the color codes...

    Private Sub Vote_BeforeUpdate(Cancel As Integer)
    If Me.AO_Vote = "Approve" And Me.Action_Complete = True Then
    Me.Vote = "Approved"
    Me.Vote.BackColor = RGB(0, 235, 0)
    Else
    Me.Vote = Me.AO_Vote
    End If


    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Should consider Conditional Formatting for coloring.

    Saving calculated data is usually not advisable. This value can be calculated when needed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    June7,
    I am playing with the colors, I already have Conditional Formatting under control. Just wanted to figure out the VBA way. I am not saving a record, just changing the output of the text when another field activates it. The original fields will stay the same. I do this becuse there are other reports that need to have the original text in them. This report would use both and would be grouped on the output and the activating field.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    This code is behind a form? Is it Continuous or Datasheet? Programmatically changing color of textbox will not work nice on those form views.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Its behind a report.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why would BeforeUpdate event be used behind a report? Data cannot be edited through report.

    Use IIf expression in textbox ControlSource:

    =IIf(AO_Vote = "Approve" And Action_Complete = True, "Approved", AO_Vote)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thank June7,
    That makes more sense. No worries about the color. i am still using the Conditional Formatting.

  8. #8
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Operand without an Operator

    What about 2 values? I have 2 of three values OK. One doesn't change.

    =IIf([Action_Complete]=True And [AO_Vote]="Approve","Approved" [AO_Vote]) Or IIf([Action_Complete]=True And [AO_Vote]="Deny","Denied" [AO_Vote])

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Not understanding your syntax. What do you mean by the the "Approved" [AO_Vote] and ,"Denied" [AO_Vote])

    This is the general IIF syntax

    =IIf([Action_Complete]=True And [AO_Vote]="Approve", ThisIfTrue,ThisIfFalse)

  10. #10
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Orange,
    That is what I am trying to get. I have this for one type:
    =IIf([Action_Complete]=True And [AO_Vote]="Approve","Approved" [AO_Vote])

    I want to add this in (Combine) also:

    = IIf([Action_Complete]=True And [AO_Vote]="Deny","Denied" [AO_Vote])

    but if I put an Or in I get the error.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    What exactly is it in plain English?
    In your example
    [Action_Complete]=True is the same in both.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Mod Edit: merged threads

    =IIf([Action_Complete]=True And [AO_Vote]="Approve", "Approved", IIf([Action_Complete]=True And [AO_Vote]="Deny", "Denied", [AO_Vote]))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks June7,
    Works, and I added to it. Much appreciated.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-23-2014, 04:35 PM
  2. Changing field value in report view in access
    By tanyapeila in forum Queries
    Replies: 2
    Last Post: 03-17-2014, 01:31 PM
  3. changing field on table from Text to Number
    By fainterm in forum Queries
    Replies: 2
    Last Post: 01-20-2014, 03:34 PM
  4. Replies: 10
    Last Post: 12-15-2013, 11:52 AM
  5. Changing field in Report
    By eww in forum Reports
    Replies: 3
    Last Post: 09-08-2010, 03:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums