P
Pete Straman Straman via AccessMonster.com
I need to write VBA code for MS Access that runs a query and sets it in
the Query Objects view. I have set up and performed operations on tables
but can not find the code to set up the query. I have to add this query
over and over to different databases and I do not want to type it out every
time I create another data.
I need to get the following queries to show up as a query object after I
process them on the form.
060004_Original
SELECT Count([060004 Original].facilityid) AS [060004 Original]
FROM [060004 Original];
060004_Appended
SELECT Count([060004].facilityid) AS [060004 Appended]
FROM 060004;
060004 AMS
SELECT Count(AMS.facilityid) AS [060004 AMS]
FROM AMS
WHERE [AMS.facilityid]=60004;
060004 BRG
SELECT Count(BRG.facilityid) AS [060004 BRG]
FROM BRG
WHERE [BRG.facilityid]=60004;
060004 Companion
SELECT Count(Companion.facilityid) AS [060004 Companion]
FROM Companion
WHERE [Companion.facilityid]=60004;
060004 Dalcon
SELECT Count(Dalcon.facilityid) AS [060004 Dalcon]
FROM Dalcon
WHERE [Dalcon.facilityid]=60004;
060004 HPAS
SELECT Count(HPAS.facilityid) AS [060004 HPAS]
FROM HPAS
WHERE [HPAS.facilityid]=60004;
060004 Medic
SELECT Count(Medic.facilityid) AS [060004 Medic]
FROM Medic
WHERE [Medic.facilityid]=60004;
060004 OMS
SELECT Count(OMS.facilityid) AS [060004 OMS]
FROM OMS
WHERE [OMS.facilityid]=60004;
Final Record Count
SELECT [060004_Original].[060004 Original] AS [060004 ORG],
[060004_Appended].[060004 Appended] AS [060004 APP], [060004 AMS].[060004
AMS] AS AMS, [060004 BRG].[060004 BRG] AS BRG, [060004 Companion].[060004
Companion] AS COM, [060004 Dalcon].[060004 Dalcon] AS DAL, [060004 HPAS].
[060004 HPAS] AS HPS, [060004 Medic].[060004 Medic] AS MED, [060004 OMS].
[060004 OMS] AS OMS, ([060004 APP]-[060004 ORG]) AS [Total Appended],
(AMS+BRG+COM+DAL+HPS+MED+OMS) AS [Total Systems], (([Total Appended])-
[Total Systems]) AS [Check]
FROM 060004_Original, 060004_Appended, [060004 AMS], [060004 BRG], [060004
Companion], [060004 Dalcon], [060004 HPAS], [060004 Medic], [060004 OMS];
trend_rpt
SELECT [060004].facilityid, Sum([060004].revenue) AS [Sum of Revenue], Sum(
[060004].payment) AS [Sum of Payments], Sum([060004].adjustment) AS [Sum
of Adjustments], [060004].transmoyr, [060004].dosmoyr
FROM 060004
GROUP BY [060004].facilityid, [060004].transmoyr, [060004].dosmoyr, [060004]
..transYear, [060004].transMonth, [060004].dosYear, [060004].dosMonth;
If you can show me how to code one I can code the rest.
Thanks in advance.
(e-mail address removed)
the Query Objects view. I have set up and performed operations on tables
but can not find the code to set up the query. I have to add this query
over and over to different databases and I do not want to type it out every
time I create another data.
I need to get the following queries to show up as a query object after I
process them on the form.
060004_Original
SELECT Count([060004 Original].facilityid) AS [060004 Original]
FROM [060004 Original];
060004_Appended
SELECT Count([060004].facilityid) AS [060004 Appended]
FROM 060004;
060004 AMS
SELECT Count(AMS.facilityid) AS [060004 AMS]
FROM AMS
WHERE [AMS.facilityid]=60004;
060004 BRG
SELECT Count(BRG.facilityid) AS [060004 BRG]
FROM BRG
WHERE [BRG.facilityid]=60004;
060004 Companion
SELECT Count(Companion.facilityid) AS [060004 Companion]
FROM Companion
WHERE [Companion.facilityid]=60004;
060004 Dalcon
SELECT Count(Dalcon.facilityid) AS [060004 Dalcon]
FROM Dalcon
WHERE [Dalcon.facilityid]=60004;
060004 HPAS
SELECT Count(HPAS.facilityid) AS [060004 HPAS]
FROM HPAS
WHERE [HPAS.facilityid]=60004;
060004 Medic
SELECT Count(Medic.facilityid) AS [060004 Medic]
FROM Medic
WHERE [Medic.facilityid]=60004;
060004 OMS
SELECT Count(OMS.facilityid) AS [060004 OMS]
FROM OMS
WHERE [OMS.facilityid]=60004;
Final Record Count
SELECT [060004_Original].[060004 Original] AS [060004 ORG],
[060004_Appended].[060004 Appended] AS [060004 APP], [060004 AMS].[060004
AMS] AS AMS, [060004 BRG].[060004 BRG] AS BRG, [060004 Companion].[060004
Companion] AS COM, [060004 Dalcon].[060004 Dalcon] AS DAL, [060004 HPAS].
[060004 HPAS] AS HPS, [060004 Medic].[060004 Medic] AS MED, [060004 OMS].
[060004 OMS] AS OMS, ([060004 APP]-[060004 ORG]) AS [Total Appended],
(AMS+BRG+COM+DAL+HPS+MED+OMS) AS [Total Systems], (([Total Appended])-
[Total Systems]) AS [Check]
FROM 060004_Original, 060004_Appended, [060004 AMS], [060004 BRG], [060004
Companion], [060004 Dalcon], [060004 HPAS], [060004 Medic], [060004 OMS];
trend_rpt
SELECT [060004].facilityid, Sum([060004].revenue) AS [Sum of Revenue], Sum(
[060004].payment) AS [Sum of Payments], Sum([060004].adjustment) AS [Sum
of Adjustments], [060004].transmoyr, [060004].dosmoyr
FROM 060004
GROUP BY [060004].facilityid, [060004].transmoyr, [060004].dosmoyr, [060004]
..transYear, [060004].transMonth, [060004].dosYear, [060004].dosMonth;
If you can show me how to code one I can code the rest.
Thanks in advance.
(e-mail address removed)