Connecting Tech Pros Worldwide Forums | Help | Site Map

Radio Button

Newbie
 
Join Date: Oct 2009
Posts: 2
#1: Oct 27 '09
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.
best answer - posted by Stewart Ross Inverness
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";"Pending"

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

Moderator
 
Join Date: Feb 2008
Location: Beauly, near Inverness, Scotland
Posts: 1,576
#2: Oct 27 '09

re: Radio Button


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";"Pending"

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
Newbie
 
Join Date: Oct 2009
Posts: 2
#3: 4 Weeks Ago

re: Radio Button


Hi,

The IIF condition worked and everything looks better now.

Thanks a lot :)
Reply