Here's the whole SQL statement. I noticed that the last item in the WHERE
clause doesn't have a quote at the end of it. If that is the problem, how
do
I get it there?
SELECT ChemDepth_Union.name_waterbody AS Lake,
ChemDepth_Union.station_name,
ChemDepth_Union.sampling_date, ChemDepth_Union.sample_type_name,
ChemDepth_Union.depth_chemalkph AS Depth, ChemAlkpH_Info.ph,
ChemAlkpH_Info.ph_note, ChemAlkpH_Info.alk, ChemAlkpH_Info.alku,
ChemNitrogenSi_Info.utn, ChemNitrogenSi_Info.no3n,
ChemNitrogenSi_Info.no3n_note, ChemNitrogenSi_Info.nh3n,
ChemNitrogenSi_Info.nh3n_note, ChemNitrogenSi_Info.si,
ChemCaMgKNa_Info.na,
ChemCaMgKNa_Info.k, ChemCaMgKNa_Info.ca, ChemCaMgKNa_Info.mg,
ChemClSO4_Info.so4s, ChemClSO4_Info.so4s_note, ChemClSO4_Info.cl,
ChemConductivity_Info.cond, ChemConductivity_Info.cond_note,
ChemDsolids_Info.dsol, ChemDsolids_Info.dsol_note, ChemPhosKjN_Info.utp,
ChemPhosKjN_Info.utp_note, ChemPhosKjN_Info.tp, ChemPhosKjN_Info.tp_note,
ChemPhosKjN_Info.op, ChemPhosKjN_Info.op_note, ChemPhosKjN_Info.utkn
FROM ChemPhosKjN_Info RIGHT JOIN (ChemDsolids_Info RIGHT JOIN
(ChemConductivity_Info RIGHT JOIN (ChemClSO4_Info RIGHT JOIN
(ChemCaMgKNa_Info RIGHT JOIN (ChemAlkpH_Info RIGHT JOIN
(ChemNitrogenSi_Info
RIGHT JOIN ChemDepth_Union ON (ChemNitrogenSi_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (ChemNitrogenSi_Info.station_name =
ChemDepth_Union.station_name) AND (ChemNitrogenSi_Info.sampling_date =
ChemDepth_Union.sampling_date) AND
(ChemNitrogenSi_Info.depth_chemnitrogensi
= ChemDepth_Union.depth_chemalkph) AND
(ChemNitrogenSi_Info.sample_type_name
= ChemDepth_Union.sample_type_name)) ON (ChemAlkpH_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (ChemAlkpH_Info.station_name =
ChemDepth_Union.station_name) AND (ChemAlkpH_Info.sampling_date =
ChemDepth_Union.sampling_date) AND (ChemAlkpH_Info.depth_chemalkph =
ChemDepth_Union.depth_chemalkph) AND (ChemAlkpH_Info.sample_type_name =
ChemDepth_Union.sample_type_name)) ON (ChemCaMgKNa_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (C
hemCaMgKNa_Info.station_name = ChemDepth_Union.station_name) AND
(ChemCaMgKNa_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemCaMgKNa_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemCaMgKNa_Info.depth_chemcamgkna = ChemDepth_Union.depth_chemalkph)) ON
(ChemClSO4_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemClSO4_Info.station_name = ChemDepth_Union.station_name) AND
(ChemClSO4_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemClSO4_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemClSO4_Info.depth_chemclso4 = ChemDepth_Union.depth_chemalkph)) ON
(ChemConductivity_Info.name_waterbody = ChemDepth_Union.name_waterbody)
AND
(ChemConductivity_Info.station_name = ChemDepth_Union.station_name) AND
(ChemConductivity_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemConductivity_Info.depth_chemconductivity =
ChemDepth_Union.depth_chemalkph) AND
(ChemConductivity_Info.sample_type_name
= ChemDepth_Union.sample_type_name)) ON (ChemDs
olids_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemDsolids_Info.station_name = ChemDepth_Union.station_name) AND
(ChemDsolids_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemDsolids_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemDsolids_Info.depth_chemdsolids = ChemDepth_Union.depth_chemalkph)) ON
(ChemPhosKjN_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemPhosKjN_Info.station_name = ChemDepth_Union.station_name) AND
(ChemPhosKjN_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemPhosKjN_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemPhosKjN_Info.depth_chemphoskjn = ChemDepth_Union.depth_chemalkph)
WHERE (((ChemDepth_Union.sampling_date) Between
[Forms]![SelectForQuery1]![startdate] And
[Forms]![SelectForQuery1]![enddate])) AND (ChemDepth_Union.name_waterbody)
IN);
SELECT ChemDepth_Union.name_waterbody AS Lake,
ChemDepth_Union.station_name,
ChemDepth_Union.sampling_date, ChemDepth_Union.sample_type_name,
ChemDepth_Union.depth_chemalkph AS Depth, ChemAlkpH_Info.ph,
ChemAlkpH_Info.ph_note, ChemAlkpH_Info.alk, ChemAlkpH_Info.alku,
ChemNitrogenSi_Info.utn, ChemNitrogenSi_Info.no3n,
ChemNitrogenSi_Info.no3n_note, ChemNitrogenSi_Info.nh3n,
ChemNitrogenSi_Info.nh3n_note, ChemNitrogenSi_Info.si,
ChemCaMgKNa_Info.na,
ChemCaMgKNa_Info.k, ChemCaMgKNa_Info.ca, ChemCaMgKNa_Info.mg,
ChemClSO4_Info.so4s, ChemClSO4_Info.so4s_note, ChemClSO4_Info.cl,
ChemConductivity_Info.cond, ChemConductivity_Info.cond_note,
ChemDsolids_Info.dsol, ChemDsolids_Info.dsol_note, ChemPhosKjN_Info.utp,
ChemPhosKjN_Info.utp_note, ChemPhosKjN_Info.tp, ChemPhosKjN_Info.tp_note,
ChemPhosKjN_Info.op, ChemPhosKjN_Info.op_note, ChemPhosKjN_Info.utkn
FROM ChemPhosKjN_Info RIGHT JOIN (ChemDsolids_Info RIGHT JOIN
(ChemConductivity_Info RIGHT JOIN (ChemClSO4_Info RIGHT JOIN
(ChemCaMgKNa_Info RIGHT JOIN (ChemAlkpH_Info RIGHT JOIN
(ChemNitrogenSi_Info
RIGHT JOIN ChemDepth_Union ON (ChemNitrogenSi_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (ChemNitrogenSi_Info.station_name =
ChemDepth_Union.station_name) AND (ChemNitrogenSi_Info.sampling_date =
ChemDepth_Union.sampling_date) AND
(ChemNitrogenSi_Info.depth_chemnitrogensi
= ChemDepth_Union.depth_chemalkph) AND
(ChemNitrogenSi_Info.sample_type_name
= ChemDepth_Union.sample_type_name)) ON (ChemAlkpH_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (ChemAlkpH_Info.station_name =
ChemDepth_Union.station_name) AND (ChemAlkpH_Info.sampling_date =
ChemDepth_Union.sampling_date) AND (ChemAlkpH_Info.depth_chemalkph =
ChemDepth_Union.depth_chemalkph) AND (ChemAlkpH_Info.sample_type_name =
ChemDepth_Union.sample_type_name)) ON (ChemCaMgKNa_Info.name_waterbody =
ChemDepth_Union.name_waterbody) AND (C
hemCaMgKNa_Info.station_name = ChemDepth_Union.station_name) AND
(ChemCaMgKNa_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemCaMgKNa_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemCaMgKNa_Info.depth_chemcamgkna = ChemDepth_Union.depth_chemalkph)) ON
(ChemClSO4_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemClSO4_Info.station_name = ChemDepth_Union.station_name) AND
(ChemClSO4_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemClSO4_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemClSO4_Info.depth_chemclso4 = ChemDepth_Union.depth_chemalkph)) ON
(ChemConductivity_Info.name_waterbody = ChemDepth_Union.name_waterbody)
AND
(ChemConductivity_Info.station_name = ChemDepth_Union.station_name) AND
(ChemConductivity_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemConductivity_Info.depth_chemconductivity =
ChemDepth_Union.depth_chemalkph) AND
(ChemConductivity_Info.sample_type_name
= ChemDepth_Union.sample_type_name)) ON (ChemDs
olids_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemDsolids_Info.station_name = ChemDepth_Union.station_name) AND
(ChemDsolids_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemDsolids_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemDsolids_Info.depth_chemdsolids = ChemDepth_Union.depth_chemalkph)) ON
(ChemPhosKjN_Info.name_waterbody = ChemDepth_Union.name_waterbody) AND
(ChemPhosKjN_Info.station_name = ChemDepth_Union.station_name) AND
(ChemPhosKjN_Info.sampling_date = ChemDepth_Union.sampling_date) AND
(ChemPhosKjN_Info.sample_type_name = ChemDepth_Union.sample_type_name) AND
(ChemPhosKjN_Info.depth_chemphoskjn = ChemDepth_Union.depth_chemalkph)
WHERE (((ChemDepth_Union.sampling_date) Between
[Forms]![SelectForQuery1]![startdate] And
[Forms]![SelectForQuery1]![enddate])) AND (ChemDepth_Union.name_waterbody)
IN( 'Blue Lake','Elizabeth Lake);
Roger Carlson said:
Okay, backing up to this again. Do me a favor, and after this line:
strSQL = strSQL & strWhere
add
debug.print strSQL
and set a BreakPoint on the line that follows. Run the code. This will
write your entire SQL statement to the Immediate Window. Copy it and
post
it here.
--
--Roger Carlson
MS Access MVP
www.rogersaccesslibrary.com
http://rogersaccessblog.blogspot.com/