yessir
Saved By Grace
- Local time
- Today, 11:28
- Joined
- May 29, 2003
- Messages
- 349
I am trying to build a dynamic query using :
here is a sample output for where:
" AND tblWater_Sample_Temp.Matrix = 'Water' AND tblWater_Sample_Temp.Outlet_ID = EN-01 AND tblWater_Sample_Temp.ClientID = 'HZ539 EN-01' AND tblWater_Sample_Temp.ProjectNo = 'H2539' AND tblWater_Sample_Temp.LabID = '04-H005638' AND tblWater_Sample_Tep"
where it should be:
" AND tblWater_Sample_Temp.Matrix = 'Water' AND tblWater_Sample_Temp.Outlet_ID = EN-01 AND tblWater_Sample_Temp.ClientID = 'HZ539 EN-01' AND tblWater_Sample_Temp.ProjectNo = 'H2539' AND tblWater_Sample_Temp.LabID = '04-H005638' AND
tblWater_Sample_Temp.SampleDate = #1/30/04# AND tblWater_Sample_Temp.Duplicate = False"
~ REALLY
Code:
'build a dynamic search clause to retrieve the information.
where = Null
If Not (Nz(rec!Matrix, "") = "") Then
where = where & " AND tblWater_Sample_Temp.Matrix = '" & rec!Matrix & "'"
End If
If Not (Nz(rec!Outlet_ID, "") = "") Then
where = where & " AND tblWater_Sample_Temp.Outlet_ID = " & rec!Outlet_ID & ""
End If
If Not (Nz(rec!ClientID, "") = "") Then
where = where & " AND tblWater_Sample_Temp.ClientID = '" & strClientID & "'"
End If
If Not (Nz(rec!ProjectNo, "") = "") Then
where = where & " AND tblWater_Sample_Temp.ProjectNo = '" & strProjectNo & "'"
End If
If Not (Nz(rec!LabID, "") = "") Then
where = where & " AND tblWater_Sample_Temp.LabID = '" & strLabID & "'"
End If
If Not (Nz(rec!SampleDate, "") = "") Then
where = where & " AND tblWater_Sample_Temp.SampleDate = #" & strDate & "#"
End If
where = where & " AND tblWater_Sample_Temp.Duplicate = " & rec!Duplicate & ""
If Not (Nz(rec!DuplicateOf, "") = "") Then
where = where & " AND tblWater_Sample_Temp.DuplicateOf = " & rec!DuplicateOf & ""
End If
If Not (Nz(rec!Elevation, "") = "") Then
where = where & " AND tblWater_Sample_Temp.Elevation = " & strElevation & ""
End If
If Not (Nz(rec!Unit_ID, "") = "") Then
where = where & " AND tblWater_Sample_Temp.Unit_ID = " & strUnitID & ""
End If
If Not (Nz(rec!DataSource, "") = "") Then
where = where & " AND tblWater_Sample_Temp.DataSource = '" & strDataSource & "'"
End If
If Not (Nz(rec!Note, "") = "") Then
where = where & " AND tblWater_Sample_Temp.Note = '" & strNote & "'"
End If
'Select the relevant information into the second recordset
Set orec = dbs.OpenRecordset("SELECT [Analyte], [Method], [Result], [Units], [DL], " & _
"[LOQ], [FlowValue], [FlowUnit_ID], [Notes] " & _
"FROM tblWater_Sample_Temp " & _
"WHERE " & Mid(where, 6) & ";")
here is a sample output for where:
" AND tblWater_Sample_Temp.Matrix = 'Water' AND tblWater_Sample_Temp.Outlet_ID = EN-01 AND tblWater_Sample_Temp.ClientID = 'HZ539 EN-01' AND tblWater_Sample_Temp.ProjectNo = 'H2539' AND tblWater_Sample_Temp.LabID = '04-H005638' AND tblWater_Sample_Tep"
where it should be:
" AND tblWater_Sample_Temp.Matrix = 'Water' AND tblWater_Sample_Temp.Outlet_ID = EN-01 AND tblWater_Sample_Temp.ClientID = 'HZ539 EN-01' AND tblWater_Sample_Temp.ProjectNo = 'H2539' AND tblWater_Sample_Temp.LabID = '04-H005638' AND
tblWater_Sample_Temp.SampleDate = #1/30/04# AND tblWater_Sample_Temp.Duplicate = False"
~ REALLY
