Ok, this allows your nulls to come through. If there is a criteria for a
field, even when using Like [Xxxx] & "*" and the field is null you must add
Or Is Null.
It also has your field labels pretty.
SELECT queryfromtesttable.ClientName AS [Client Name],
queryfromtesttable.CollectedDate AS [Collected Date],
queryfromtesttable.location, queryfromtesttable.sample_number AS [Sample
Number], queryfromtesttable.TestType AS [Test Type],
queryfromtesttable.KitReturned AS [Kit Returned],
queryfromtesttable.DateofTest AS [Date of Test],
queryfromtesttable.testresult AS [Test Result],
queryfromtesttable.Averagetestresult AS [Average test result],
queryfromtesttable.sample_Tempertature AS [Sample Tempertature]
FROM queryfromtesttable
WHERE (((queryfromtesttable.ClientName) Like [Enter client name] & "*" Or
(queryfromtesttable.ClientName) Is Null) AND
((queryfromtesttable.CollectedDate)>=[Beginning Date] And
(queryfromtesttable.CollectedDate)<=[Ending Date]) AND
((queryfromtesttable.TestType) Like [Test type sought] & "*" Or
(queryfromtesttable.TestType) Is Null));
Joshua K Briley said:
I've changed the names of some of the fields so they would make sense to the
reader. The spelling of the field names can be overlooked. Can this be
rewritten as to show the location, even though there are no corresponding
test results? Or is that something that needs to be handled in the report
itself?
--
Somecallmejosh
:
You had typos. Field names must match exactly. One missing opening [.
SELECT queryfromtesttable.ClientName, queryfromtesttable.CollectedDate,
queryfromtesttable.location, queryfromtesttable.sample_number,
queryfromtesttable.TestType, queryfromtesttable.KitReturned,
queryfromtesttable.DateofTest, queryfromtesttable.testresult,
queryfromtesttable.Averagetestresult, queryfromtesttable.sample_Tempertature
FROM queryfromtesttable
WHERE (((queryfromtesttable.ClientName) Like [Enter client name] & "*") AND
((queryfromtesttable.CollectedDate)>=[Beginning Date] And
(queryfromtesttable.CollectedDate)<=[Ending Date]) AND
((queryfromtesttable.TestType) Like [Test type sought] & "*"));
:
SELECT [Client Name],
[location],
[Collected Date],
[sample_number],
[Test Type],
[Kit Returned],
[Date of Test],
[testresult],
[Averagetestresult],
[sample_Tempertature]
FROM [queryfromtesttable]
WHERE ((([queryfromtesttable].[Client Name]) Like "clientname*")
AND (([queryfromtesttable].[Collected Date])>=[Beginning Date]
And ([queryfromtesttable].[Collected Date])<=[Ending Date])
AND (([queryfromtesttable].[Test Type]) Like "test type sought"
Or([queryfromtesttable].Test Type]) Like "different test type sought"));
--
Somecallmejosh
:
Post your query.
:
I have a report that includes [test_results] which are subcategorized by
client [location]. I'd like the report to show the [location], even if there
are no [test_results] recorded for that [location]. The query supporting the
report is based on a date range in which the test was conducted.
I hope I've given enough information for this to make sense. Is it possible
to pull in these [locations] without [test_results]? Any advice will be
greatly appreciated.