Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

If a field = 0 then display text?

Posted on 2018-01-12
7
Low Priority
?
25 Views
Last Modified: 2018-01-12
Is there a way in access to display certain text if a field = a certain number. For example if PH_STATUS = 0 then display closed IF PH_STATUS = 1 then display OPEN. I am not sure how to do this within access. Any help would be much appreciated!
0
Comment
Question by:HOTWATT
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 15

Expert Comment

by:Dustin Saunders
There are a couple of ways to do that, but the better question is:

Are there only 2 statuses or are there multiple ones?

You will probably want a separate table for your statuses and then you can reference those values on your display.  Is that the case?
0
 
LVL 49

Assisted Solution

by:Dale Fye
Dale Fye earned 400 total points
in a textbox, you can set the ControlSource to:

=IIF([PH_Status]=0, 'Closed', 'Open')

But if you are talking about hiding a field based on the value of [PH_Status] you would have to use the FORM_Current and AfterUpdate event of the control that contains the value for [PH_Status] to then hide/reveal some other control, something like:

Private Sub txt_PH_Status_AfterUpdate

    me.SomeControlName.Visible = ([PH_Status] = 1)
0
 
LVL 59

Accepted Solution

by:
Bill Prew earned 600 total points
You can use the IIF() function, in a query.

If the valuses are always either 0 or 1 then:

IIF(PH_STATUS = 1, 'OPEN', 'CLOSED')

If there can be other values then:

IIF(PH_STATUS = 1, 'OPEN', IIF(PH_STATUS = 0, 'CLOSED', ''))


»bp
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:HOTWATT
there are more statuses but we are just looking at closed and open right now which are 0 and 1
0
 

Author Closing Comment

by:HOTWATT
Thanks for the help! Bill that worked perfectly!
0
 
LVL 59

Expert Comment

by:Bill Prew
Great, glad that helped.


»bp
0
 
LVL 15

Expert Comment

by:Dustin Saunders
there are more statuses but we are just looking at closed and open right now which are 0 and 1

You should go ahead and design your form to accommodate this then.  Rather than a text field, you should make that a combo box that contains your status values, a few reasons off the cuff:

>You can add new statuses easily when needed.
>You can retire old statuses and retain their value as it was if desired by adding an 'Active' column to your statuses.
>Without this, any form you implement changes on will not be the same as others.  You have to go touch EACH place you have that condition.
>The combo box enforces data validation.
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Join & Write a Comment

Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question