Union query

  • Thread starter Thread starter Ayala
  • Start date Start date
A

Ayala

Hi, I build a union query

SELECT GenDataID, Measure, StartTorque, RatedSpeed,
MaxSpeed, " ", " ", "Nominal Data" as [Measurement]
FROM qryNominalData
UNION SELECT GenDataID, SubProduct, Readings,
Value, " ", " ", " ", "VMS Readings"
FROM qryVMSReadings
UNION SELECT GenDataID, SubProduct, AGSensor,
VMSIndication, VoltageReadonDisplay, " ", " ", "Air Gap"
FROM qryAirGap
UNION SELECT GenDataID, SubProduct, RecoolingSysSensor,
IndicationDisplayVMS, " ", " ", " ", "Recooling System"
FROM qryRecoolingSys
UNION SELECT GenDataID, SubProduct, RingMeasurements,
PT100, TempDisplayVMS, AlarmSetPoint, TripSetPoint, "Check
Measurements"
FROM qryCheckMeasurements
ORDER BY [Measurement];

then I make the recordset of this query. Now I want to
filter on Measurement so I can get the data separately
for "Nominal Data", "Vms Readings", "Air Gap", etc.

the statement look like:

dim strFiltro as string
strFiltro = rstData!Measurement Like "Nominal Data"
or
strFiltro = rstData!Measurement Like "Air Gap"
rstData.Filter = strFiltro

But then I get this:
Error -2147217908: Command text was not set for the
command object


Can someone guide me in the right way of filtering my
recordset?
thx
 
Hi,


Something like:



rst.Filter = "Measurement = 'Nominal Data' "
Set OtherRst = rst.OpenRecordset


ie. specify the filter first, then, to see its effect, open another
recordset based on the first one.



Hoping it may help,
Vanderghast, Access MVP
 
Now I want to
filter on Measurement so I can get the data separately
for "Nominal Data", "Vms Readings", "Air Gap", etc.

You'll need to base a second query on the stored UNION query, grouping
by the field and displaying whatever other information you want to
see.
 
Back
Top