Radio Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • memi
    New Member
    • Oct 2009
    • 2

    Radio Button

    Hi,

    I have a Radio Button with label "Status" in my form to choose between two options:
    "Pending" or "Completed" .

    The problem is when I display the "Status" field in a report. It gives me either "Yes" if the status is pending or "No" if the status is completed. These values (Yes or No) don't make sense to the end user. I want to change the display to be either "Pending" or "Completed" . How can I do this?

    p.s. I have no background in Visual Basic.
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi, and Welcome to Bytes!

    It appears that your Status field is being represented as a Boolean value - one that is represented by True/False, Yes/No (internally stored as an integer value, -1 for True/Yes and 0 for False/No).

    If this is so you can change the formatting of the textbox in your report and apply a custom format to display "Pending" or "Completed" instead of "Yes" and "No". Open your report in design view and select the Status text box. If the properties tabs are not open right-click and select Properties. Have a look at the Format property of the property tabs. It may say Yes/No at present. Change this to the following text:

    ;"Completed";"P ending"

    The opening semicolon is deliberate and must be included.

    What this does is to apply a custom format to a numeric value. In this case, there is no format for positive values (>0) - hence the lone semicolon at the start. The text "Completed" is in the second position - which is what to display if the value is negative (<0). The text "Pending" is in the third position - which is what to display if the value is 0. There is no need for a fourth choice in this instance - which would be what to display if the field is null.

    Alternatively, if you cannot make this work, you can take a different approach by using a calculated field instead. To do this, select the existing textbox for your status field and change its name property to something not bound to one of the underlying fields in your query or table (e.g. txtStatusText). Change the ControlSource property from Status to

    =IIF([Status] = 0, "Pending", "Completed" )

    Both approaches assume that status "Pending" is represented by 0 and "Completed" by -1. If this is not the case the custom format approach is unlikely to work, but the calculated field can easily be adapted by changing the value tested in the IIF statement.

    Neither approach requires any VBA at all.

    -Stewart

    Comment

    • memi
      New Member
      • Oct 2009
      • 2

      #3
      Hi,

      The IIF condition worked and everything looks better now.

      Thanks a lot :)

      Comment

      Working...