|
 |
access thread: SQL translation from QEB to DAO
Message #1 by "Ken Mercer" <kmercer@n...> on Sat, 10 Mar 2001 23:37:12 +0200
|
|
I'm still fairly new to Access but please can someone explain why (using
Access 2000) when I create a simple query in the QEB facility (which
works perfectly), the SQL that the QEB generates cannot be used directly
in the DAO environment. Taking a simple example - the SQL from the QEB
is the following :
SELECT CallBackDateTime, RepairStartDateTime,
DateDiff("n",[CallbackDateTime],[RepairStartDateTime])) AS ResponseTime
FROM LiftPerformanceData
In the QEB facility this works perfectly. Now using this SQL in the DAO
environment as shown below doesn't work.
Set objDb =3D CurrentDb()
strSQL =3D "SELECT CallbackDateTime, RepairStartDateTime, ' _
& "(DateDiff("n",[CallbackDateTime],[RepairStartDateTime])) AS
ResponseTime, " _
& "FROM LiftPerformanceData " _
Set objQD =3D objDb.CreateQueryDef("QueryDataSet2", strSQL)
"End of statement expected error" with the "n" in the string as well as
the DateDiff function in the SQL statement seems to be the problem. How
do I solve this and why is this DAO SQL different to the QEB SQL (if
indeed it is)?.
Many thanks for the help.
Ken Mercer
kmercer@n...
Message #2 by "John Ruff" <papparuff@c...> on Sun, 11 Mar 2001 13:01:50 -0800
|
|
Ken
Any time you have quotes within quotes in a SQL string, the second set of
quotes must be single quotes(''), instead of double quotes ( ""). Change
your code to the following:
SELECT CallBackDateTime, RepairStartDateTime,
DateDiff('n',[CallbackDateTime],[RepairStartDateTime])) AS ResponseTime
FROM LiftPerformanceData
Where the DateDiff("n",... is DateDiff('n',...
John Ruff - The Eternal Optimist :)
-----Original Message-----
From: Ken Mercer [mailto:kmercer@n...]
Sent: Saturday, March 10, 2001 1:37 PM
To: Access
Subject: [access] SQL translation from QEB to DAO
I'm still fairly new to Access but please can someone explain why (using
Access 2000) when I create a simple query in the QEB facility (which works
perfectly), the SQL that the QEB generates cannot be used directly in the
DAO environment. Taking a simple example - the SQL from the QEB is the
following :
SELECT CallBackDateTime, RepairStartDateTime,
DateDiff("n",[CallbackDateTime],[RepairStartDateTime])) AS ResponseTime
FROM LiftPerformanceData
In the QEB facility this works perfectly. Now using this SQL in the DAO
environment as shown below doesn't work.
Set objDb = CurrentDb()
strSQL = "SELECT CallbackDateTime, RepairStartDateTime, ' _
& "(DateDiff("n",[CallbackDateTime],[RepairStartDateTime])) AS ResponseTime,
" _
& "FROM LiftPerformanceData " _
Set objQD = objDb.CreateQueryDef("QueryDataSet2", strSQL)
"End of statement expected error" with the "n" in the string as well as the
DateDiff function in the SQL statement seems to be the problem. How do I
solve this and why is this DAO SQL different to the QEB SQL (if indeed it
is)?.
Many thanks for the help.
Ken Mercer
kmercer@n...
|
|
 |