Solved

Access Report - If Statement help

Posted on 2004-10-13
5
1,665 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

821 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