ahmedjamalaboelez
Ahmed J. Aboelez
- Local time
- Yesterday, 20:11
- Joined
- Feb 25, 2015
- Messages
- 79
Gentlemen,
Company (IT) team provide me with SQL Server Query which result in sales query , no errors while running on our MS SQL Server Machine , i already linked required tables in my access database because i need to make more advanced reports , but i can not write this kind of queries in access and team mate have no knowledge about access queries
:banghead: Question : is there any way to send this query to SQL server in VBA Code , and drop the result in my sub form
Notes :
Thread Not Published in Any other Forums
Any Help Regarding This Thread will be appreciated
Thanks
Company (IT) team provide me with SQL Server Query which result in sales query , no errors while running on our MS SQL Server Machine , i already linked required tables in my access database because i need to make more advanced reports , but i can not write this kind of queries in access and team mate have no knowledge about access queries
:banghead: Question : is there any way to send this query to SQL server in VBA Code , and drop the result in my sub form
Notes :
Thread Not Published in Any other Forums

Any Help Regarding This Thread will be appreciated

Thanks

Code:
Select
lok_nazwa As Location,
DSN_PelnyNrDokumentu [Shift No.],
format(dsn_datadokumentu,'yy')+convert (varchar,lok_nr)+convert (varchar,DSR_NrRachunku) [Bill Number],
Format(DSR_DataZamkniecia,'yyyy-dd-MM hh:mm tt' ) [DATE],
ART_nr As [Item No.],
ART_Nazwa [Item Name],
SUM (DSL_Ilosc)[Qty],
Sum(dsl_ilosc*DSL_CenaSprzedazyNetto) [Net Total],
Sum(dsl_ilosc*DSL_CenaSprzedazyBrutto) [Total],
(Sum(dsl_ilosc*DSL_CenaSprzedazyBrutto))-(Sum(dsl_ilosc*DSL_CenaSprzedazyNetto)) VAT,
FP1.FPL_ID [FOP1 ID],
FP1.FPL_Nazwa [FOP1],
SUM(DSL_KwotaFP1) as [FP1 Amount],
SUM(DSL_FPLID2) as [FOP ID2],
(select FPL_Nazwa [FOP2] from FPL_FormyPlatnosci where SUM(DSL_FPLID2) is not null and FPL_ID=SUM(DSL_FPLID2)),
SUM(DSL_KwotaFP2) as [FP2 Amount],
TOR_Nazwa [T.O.O]
from DSL_DokumentySprzedazyLinijki
Left Outer Join DSR_DokumentySprzedazyRachunki on DSR_ID=DSL_DSRID
JOIN TOR_TypyOtwarciaRachunku ON TOR_ID=DSR_TORID
Left Outer JOIN SSG_StanowiskaSprzedazyGrupy ON SSG_ID=DSR_SSGID
Left Outer JOIN LOK_Lokale ON LOK_ID=SSG_LOKID
JOIN FPL_FormyPlatnosci FP1 ON FP1.FPL_ID=DSL_FPLID1
JOIN ART_Artykuly ON ART_ID=DSL_ARTID
Left Outer JOIN DSN_DokumentySprzedazyNaglowki ON DSN_ID=DSL_DSNID
where DSL_DataStorna is null and DSR_DataZamkniecia is not null and DSR_DataZamkniecia between '2019-01-01 00:00:00' and '2019-01-01 23:59:00' and DSL_DSLIDPowiazana is null
Group by lok_nazwa,
format(dsn_datadokumentu,'yy')+convert (varchar,lok_nr)+convert (varchar,DSR_NrRachunku) ,
DSN_PelnyNrDokumentu,
DSR_DataZamkniecia,
ART_nr ,
ART_Nazwa,
FP1.FPL_ID,
FP1.FPL_Nazwa,
TOR_Nazwa
Order by [DATE],[Location],[Shift No.],[Bill Number]