Solved

Access Report - If Statement help

Posted on 2004-10-13
5
1,661 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
5 Comments
 
LVL 8

Assisted Solution

by:jb79uk
jb79uk earned 150 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 84
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 100 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now