Hi all!
Thanks for a great forum!
I have an issue that crops up when I try use a VBA function with a query.
It works fine UNITIL I add the Totals Row ( in design view ).
I had GroupBy and this gave me the titled ( above error ).
I also tried using a mixture of GroupBy and Expression ( on the VBA modified field ).
This gave an error:
Here is my second attempt:
Both gave the same errors.
I have trawled the internet and none come close.
What am I doing wrong?
Thanks for our forthcoming help
Thank you,
Kind regards
Triacona
Thanks for a great forum!
I have an issue that crops up when I try use a VBA function with a query.
It works fine UNITIL I add the Totals Row ( in design view ).
I had GroupBy and this gave me the titled ( above error ).
So instead of GroupBy I used Expression in the Totals values for all fields, same error.SQL error said:you tried to execute a query that does not include the specified expression as part of an aggregate
I also tried using a mixture of GroupBy and Expression ( on the VBA modified field ).
This gave an error:
Below is the first iteration of my SQL:data mismatch error said:Data mismatch
Code:
SELECT
UNI7LIVE_LIPARTY.FULLNAME,
Carriage([UNI7LIVE_LIPARTY].[ADDRESS]) AS LiPAddressCr,
UNI7LIVE_LICASE.ACTCOMND AS DateGranted,
UNI7LIVE_LICASE.LICDETAILS AS LicenceDetails,
UNI7LIVE_LICASE.LICNTYPE AS LicenceType,
UNI7LIVE_LICASE.REFVAL AS LicenseNo,
OneLineReplace([UNI7LIVE_LICASE].[ADDRESS]) AS SiteAddressOL,
UNI7LIVE_PR_LPI.ADDRESS,
UNI7LIVE_PR_LPI.POSTCODE,
First(UNI7LIVE_LIACTTIM.LOCATION) AS Location,
UNI7LIVE_LIACTTIM.LIPERMIT,
UNI7LIVE_LICASE.LISTAT,
UNI7LIVE_LIPARTY.LIPTYTYPE,
UNI7LIVE_CNAPPLLOG.REFVAL,
UNI7LIVE_CNAPPLLOG.STATUS,
UNI7LIVE_CNAPPLLOG.OPENDD,
UNI7LIVE_PR_LPI.LOGICAL_STATUS AS PrLpiLogicalStat,
UNI7LIVE_PR_BLPU.LOGICAL_STATUS AS BlpuLogicalStat
FROM
((((UNI7LIVE_LICASE
LEFT JOIN UNI7LIVE_LIPARTY
ON UNI7LIVE_LICASE.KEYVAL = UNI7LIVE_LIPARTY.PKEYVAL)
LEFT JOIN UNI7LIVE_CNAPPLLOG
ON UNI7LIVE_LICASE.LIKEYVAL = UNI7LIVE_CNAPPLLOG.KEYVAL)
LEFT JOIN UNI7LIVE_LIACTTIM
ON UNI7LIVE_LICASE.KEYVAL = UNI7LIVE_LIACTTIM.PKEYVAL)
LEFT JOIN UNI7LIVE_PR_BLPU
ON UNI7LIVE_LICASE.PRKEYVAL = UNI7LIVE_PR_BLPU.KEYVAL)
LEFT JOIN UNI7LIVE_PR_LPI
ON UNI7LIVE_PR_BLPU.KEYVAL = UNI7LIVE_PR_LPI.PKEYVAL
GROUP BY
UNI7LIVE_LIPARTY.FULLNAME,
UNI7LIVE_LICASE.ACTCOMND,
UNI7LIVE_LICASE.LICDETAILS,
UNI7LIVE_LICASE.LICNTYPE,
UNI7LIVE_LICASE.REFVAL,
UNI7LIVE_PR_LPI.ADDRESS,
UNI7LIVE_PR_LPI.POSTCODE,
UNI7LIVE_LIACTTIM.LIPERMIT,
UNI7LIVE_LICASE.LISTAT,
UNI7LIVE_LIPARTY.LIPTYTYPE,
UNI7LIVE_CNAPPLLOG.REFVAL,
UNI7LIVE_CNAPPLLOG.STATUS,
UNI7LIVE_CNAPPLLOG.OPENDD,
UNI7LIVE_PR_LPI.LOGICAL_STATUS,
UNI7LIVE_PR_BLPU.LOGICAL_STATUS
HAVING
(((UNI7LIVE_LICASE.LICNTYPE) In ("PREMIS","CLUB"))
AND ((UNI7LIVE_LIACTTIM.LIPERMIT)="ALCRET")
AND ((UNI7LIVE_LICASE.LISTAT)="5_ISS")
AND ((UNI7LIVE_LIPARTY.LIPTYTYPE) Not In ("DPS","LIAGNT","LIREP"))
AND ((UNI7LIVE_PR_LPI.LOGICAL_STATUS) In ("1")));
Here is my second attempt:
Code:
SELECT
UNI7LIVE_LIPARTY.FULLNAME,
Carriage([UNI7LIVE_LIPARTY].[ADDRESS]) AS LiPAddressCr,
UNI7LIVE_LICASE.ACTCOMND AS DateGranted,
UNI7LIVE_LICASE.LICDETAILS AS LicenceDetails,
UNI7LIVE_LICASE.LICNTYPE AS LicenceType,
UNI7LIVE_LICASE.REFVAL AS LicenseNo,
OneLineReplace([UNI7LIVE_LICASE].[ADDRESS]) AS SiteAddressOL,
UNI7LIVE_PR_LPI.ADDRESS,
UNI7LIVE_PR_LPI.POSTCODE,
UNI7LIVE_LIACTTIM.LOCATION AS Location,
UNI7LIVE_LICASE.CPTRADEAS AS TradingAs,
UNI7LIVE_LIACTTIM.LIPERMIT,
UNI7LIVE_LICASE.LISTAT,
UNI7LIVE_LIPARTY.LIPTYTYPE,
UNI7LIVE_CNAPPLLOG.REFVAL,
UNI7LIVE_CNAPPLLOG.STATUS,
UNI7LIVE_CNAPPLLOG.OPENDD,
UNI7LIVE_PR_LPI.LOGICAL_STATUS AS PrLpiLogicalStat,
UNI7LIVE_PR_BLPU.LOGICAL_STATUS AS BlpuLogicalStat
FROM
((((UNI7LIVE_LICASE
LEFT JOIN UNI7LIVE_LIPARTY
ON UNI7LIVE_LICASE.KEYVAL = UNI7LIVE_LIPARTY.PKEYVAL)
LEFT JOIN UNI7LIVE_CNAPPLLOG
ON UNI7LIVE_LICASE.LIKEYVAL = UNI7LIVE_CNAPPLLOG.KEYVAL)
LEFT JOIN UNI7LIVE_LIACTTIM
ON UNI7LIVE_LICASE.KEYVAL = UNI7LIVE_LIACTTIM.PKEYVAL)
LEFT JOIN UNI7LIVE_PR_BLPU
ON UNI7LIVE_LICASE.PRKEYVAL = UNI7LIVE_PR_BLPU.KEYVAL)
LEFT JOIN UNI7LIVE_PR_LPI
ON UNI7LIVE_PR_BLPU.KEYVAL = UNI7LIVE_PR_LPI.PKEYVAL
GROUP BY
UNI7LIVE_LIPARTY.FULLNAME,
UNI7LIVE_LICASE.ACTCOMND,
UNI7LIVE_LICASE.LICDETAILS,
UNI7LIVE_LICASE.LICNTYPE,
UNI7LIVE_LICASE.REFVAL,
OneLineReplace([UNI7LIVE_LICASE].[ADDRESS]),
UNI7LIVE_PR_LPI.ADDRESS,
UNI7LIVE_PR_LPI.POSTCODE,
UNI7LIVE_LIACTTIM.LOCATION,
UNI7LIVE_LICASE.CPTRADEAS,
UNI7LIVE_LIACTTIM.LIPERMIT,
UNI7LIVE_LICASE.LISTAT,
UNI7LIVE_LIPARTY.LIPTYTYPE,
UNI7LIVE_CNAPPLLOG.REFVAL,
UNI7LIVE_CNAPPLLOG.STATUS,
UNI7LIVE_CNAPPLLOG.OPENDD,
UNI7LIVE_PR_LPI.LOGICAL_STATUS,
UNI7LIVE_PR_BLPU.LOGICAL_STATUS
HAVING
(((UNI7LIVE_LICASE.LICNTYPE) In ("PREMIS","CLUB"))
AND ((UNI7LIVE_LIACTTIM.LIPERMIT)="ALCRET")
AND ((UNI7LIVE_LICASE.LISTAT)="5_ISS")
AND ((UNI7LIVE_LIPARTY.LIPTYTYPE) Not In ("DPS","LIAGNT","LIREP"))
AND ((UNI7LIVE_PR_LPI.LOGICAL_STATUS) In ("1")));
I have trawled the internet and none come close.
What am I doing wrong?
Thanks for our forthcoming help
Thank you,
Kind regards
Triacona