Solved

Correct syntax for report

Posted on 2013-11-02
4
311 Views
Last Modified: 2013-11-02
I have a report with a solution from EE..... which is working great (Thanks!)

In the working report I have a text box with the control source as:

=[CountOfFrameModel]/DCount("FrameModel","tmain","frameLine='" & [FrameLine] & "'and tMain.FrameOWF = False and tMain.Status <> 'Cancelled'")


I would also like to add anothe criteria based on a form selection but can't find the syntax.... The form is [Form]![fReportSelect]![LocSelect]

The only catch is that there are 3 locations possible and "ALL"

So while I would like to add the "locseelct" to the text box's control source but also keep as it is above when "All" is selected from the locselect on the form.

Is this possible?  If I could get the syntax correct I thought perhaps of using an IF statement in the control box.
0
Comment
Question by:thandel
  • 3
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 39618989
Try this:

=[CountOfFrameModel]/DCount("FrameModel","tmain","frameLine='" & [FrameLine] & "'and tMain.FrameOWF = False and tMain.Status <> 'Cancelled' AND locseelct LIKE '" & iif("" & [Form]![fReportSelect]![LocSelect] = "All", "*", "" & [Form]![fReportSelect]![LocSelect]) & "'")

Open in new window

0
 
LVL 61

Expert Comment

by:mbizup
ID: 39618997
Hmm... I copied the field name "locseelct" directly from your original post.

It looks like a typo to me, though.  If you have issues with what I posted, try using "locselect" instead of "locseelct"

=[CountOfFrameModel]/DCount("FrameModel","tmain","frameLine='" & [FrameLine] & "'and tMain.FrameOWF = False and tMain.Status <> 'Cancelled' AND locselect LIKE '" & iif("" & [Form]![fReportSelect]![LocSelect] = "All", "*", "" & [Form]![fReportSelect]![LocSelect]) & "'")

Open in new window

0
 

Author Comment

by:thandel
ID: 39619020
Thanks minor correction and added tMain.office but

=[CountOfFrameModel]/DCount("FrameModel","tmain","frameLine='" & [FrameLine] & "'and tMain.FrameOWF = False and tMain.Status <> 'Cancelled' AND  tMain.Office LIKE '" & IIf("" & Form!fReportSelect!LocSelect="All","*","" & Form!fReportSelect!LocSelect) & "'")

Is prompting for "Form".  I think Form!fReportSelect!LocSelect needs to be [Form]![fReportSelect]![LocSelect]
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39619037
Ooops ... actually it needs to be Forms!   (with an s):


=[CountOfFrameModel]/DCount("FrameModel","tmain","frameLine='" & [FrameLine] & "'and tMain.FrameOWF = False and tMain.Status <> 'Cancelled' AND  tMain.Office LIKE '" & IIf("" & Forms!fReportSelect!LocSelect="All","*","" & Forms!fReportSelect!LocSelect) & "'")

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

792 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