Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 2nd, 2004, 10:39 PM
Registered User
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Expressions and Parametres

Hi all,

I have a situation in selecting data for a Crystal report that I am not sure how to tackle, I'm hoping that someone out there can point me in the right direction.

For simplicity, I'm going to boil down my issue to two tables: I am selecting data from PurchaseOrders table which contains the columns: Number, LocationName, AccountCode, etc where the Location column is sourced from a view called vwLocation. Content of vwLocation is LocationName and AccountCode. They are joined on LocationName.

I have a Crystal parametre field created on vwLocation.LocationName so that all PurchaseOrders are returned for the LocationName entered, say LocationName = 'ABC'. That's working fine, however there's a complication: When creating PurchaseOrders, application users can select a LocationName for the purchase order, but then change the value of the AccountCode so that it's different from the one that's created by the vwLocation. For example: the AccountCode for 'ABC' is 258, users create the PO for Location XYZ and enter AccountCode 258.

My Crystal selection needs to change so that it not only selects PurchaseOrders having a LocationName of 'ABC' but also an AccountCode of 258

Now, I can get this working in a SQL Query Analyzer really easily with the following SQL:

SELECT PurchaseOrder.PurchaseOrder, PurchaseOrder.LocationName, PurchaseOrder.AccountCode
FROM vwLocation INNER JOIN PurchaseOrders ON vwLocation.LocationName = PurchaseOrders.LocationName
WHERE PurchaseOrder.LocationName = 'ABC' OR
PurchaseOrder.AccountCode = (SELECT AccountCode FROM vwLocation WHERE LocationName = 'ABC')

In my Crystal report I have a parametre called ?Location which the select expert uses to select from PurchaseOrders. I created an SQL Expression to bring back the AccountCode from vwLocation and added it the the select expert. The last part of the puzzle it to have the ?Location parametre also exist against the SQL Expression... so that the user is only ever prompted for one LocationName parametre. How can I do that? Or maybe you can think of a better way...

You may be thinking: "Just use the AccountCode as the only selection criteria." Unfortunately, the report is designed for end users, who are more familiar with LocationNames than they are AccountCodes and the aim of the game is to keep the end users happy.

I really hope someone can help!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Error using SQL Expressions gulien Crystal Reports 0 December 9th, 2006 04:07 AM
SQL Expressions shazia1 Crystal Reports 0 June 15th, 2006 05:20 AM
CRAXDRT Error - SQL Expressions sreedhar Crystal Reports 0 July 12th, 2004 06:34 AM
SQL Expressions Fields dotty69 Crystal Reports 2 January 23rd, 2004 10:38 AM
Regular Expressions Dave Doknjas C# 1 August 9th, 2003 12:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.