Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Access Report - If Statement help

Posted on 2004-10-13
5
Medium Priority
?
1,677 Views
Last Modified: 2013-11-28
I have written an If statement to allow me to display (on a report) which box was selected on a Form:

=IIf(Forms![Main Menu]!OpenCheck=-1,"Open","") & IIf(Forms![Main Menu]!ClosedCheck=-1,"Closed","")

This currently displays 'Open', 'Closed', or 'OpenClosed'

I want it to display 'Open', 'Closed', or 'Open and Closed'

Please help.
Scotto13


0
Comment
Question by:Scotto13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 8

Assisted Solution

by:James Bendall
James Bendall earned 600 total points
ID: 12301115
How about:

=IIf(Forms![Main Menu]!OpenCheck=-1,IIf(Forms![Main Menu]!ClosedCheck=-1,"Open and Closed","Open"),"") & IIf(Forms![Main Menu]!ClosedCheck=-1,"Closed","")

Hope this helps

JB
0
 
LVL 85
ID: 12301121
This is probably more easily done in the Format of the section containing your control:

Sub Detail_Format()

Dim strShow As String

If Forms![Main Menu]!OpenCheck= True Then
  strShow = "Open"
End If

If Forms![Main Menu]!ClosedCheck= True Then
  If Len(strShow)=0 Then
    strShow = "Closed"
  Else
    strShow = strShow & " and Closed"
  End If
End If

Me.YourControlName = strShow

End Sub
0
 
LVL 15

Accepted Solution

by:
will_scarlet7 earned 400 total points
ID: 12301301
a small tweak to JB's suggestion:

=IIf(Forms![Main Menu]!OpenCheck=-1,"Open", "") & IIf(Forms![Main Menu]!ClosedCheck=-1,Iif(Forms![Main Menu]!OpenCheck=-1, " And Closed","Close"), "")
0
 

Author Comment

by:Scotto13
ID: 12301361
Thank you Will.  I was trying to edit JBs code but could not figure it out.  I'll split the points...
0
 
LVL 15

Expert Comment

by:will_scarlet7
ID: 12302452
Glad I could be a help.
God bless!

Sam
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

597 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