Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Command with Parameters to Pull from Access DB Post Reply Post New Topic
Author Message
vcs1161
Newbie
Newbie


Joined: 03 Mar 2010
Online Status: Offline
Posts: 33
Quote vcs1161 Replybullet Topic: Command with Parameters to Pull from Access DB
    Posted: 19 Jan 2015 at 4:04am
I have the following command that works to pull data from an Access Database but am having problems creating an automated range:
 

SELECT

`ProductType`.`TypeName`,

`Entry_Details`.`RecordID`,

 `Entry_Details`.`Date`,

`Entry_Details`.`TransInitials`,

`Products`.`ProductDesc`,

 `Entry_Details`.`PRodTypeID`,

`Entry_Details`.`ProdID`,

`Entry_Details`.`EntryPrsnID`

 `Employees`.`FullName`,

`Employees`.`Status`,

`Employees`.`PrsnID`

 FROM 

`Entry_Details`,

`Products`,

`Employees`,

`ProductType`

WHERE

(`Entry_Details`.`Date`>= {?BeginDate} AND `Entry_Details`.`Date`< {?EndDate})

And

`Entry_Details`.`EntryPrsnID`=`Employees`.`PrsnID`

And `Entry_Details`.`ProdID` = `Products`.`ProductID`

And `Products`.`ProdTypeID`=`ProductType`.`TypeID`

I have used this format preceding this type of code when running SQL against an SQL server environment for other reports:

 

Declare

@start smalldatetime,

@end smalldatetime

 

declare
@start smalldatetime,
@end smalldatetime

 

if {?BeginDate}={?EndDate} begin
select
@end = getdate(),
select
@start = dateadd('d',-30,@end)
end
else begin
select
@start = {?BeginDate},
@end = {?EndDate}
end
Then my select statement would apply the date range based on the values for the @start and @end.  I get the following error message:

 

Database Connector Error 'DAO Error Code: 0xc06

Source: DAO.Database

Description: The Microsoft Jet database engine cannot find the input table or query 'declare @start smalldatetime, @end smalldatetime

 

If #2015-01-19#=#2015-01-19# begin

select
@end = getdate(),
select
@start = dateadd('d',-30,@end)
end
else begin
etc...

 

Is there a syntax format that works the same and I just don't have that right based on reading from an Access DB?  Any suggestions is greatly appreciated.

 

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 28 Jan 2015 at 6:15am
I don't think you'll be able to do it this way - I've had issues trying to get variables to work in queries. However, there is a way around this in the Where clause. It looks like this (replace the first line of the where clause...):

Where
(({?BeginDate} = {?EndDate} and
   'Entry Details'.'Date' >= dateadd('d',-30,{?EndDate}) and 'Entry Details'.'Date' < GetDate()) OR
('Entry Details'.'Date' >= {?BeginDate} and 'Entry Details'.'Date' < {?EndDate}))

-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.