Access 2000 query help

G

Gale Coleman

Hello all,

I am trying to design a query that will give me a search field. I want to
be able to search a number of fields in a database for a certain word or
words. I am having a problem with the query working properly when there is
nothing in the field. The query comes up blank.

Is there something that I can code so it will give me the results even if
the fields are blank?

Following is the SQL:

SELECT [Choices].[ChoicesName]+' '+[ChoicesDescription]+'
'+[Documents].[DocName1]+' '+[Documents].[DocName2]+'
'+[Documents].[DocName3]+' '+[Documents].[DocName4]+'
'+[Documents].[DocName5]+' '+[Documents].[DocName6]+'
'+[Documents].[DocName7]+' '+[Documents].[DocName8]+'
'+[Documents].[DocName9]+' '+[Documents].[DocName10] AS searchfield,
Choices.ChoicesDescription, Choices.ChoicesName, CaseTypes.CaseType,
Choices.ChoicesID, Documents.DocName1, Documents.DocName2,
Documents.DocName3, Documents.DocName4, Documents.DocName5,
Documents.DocName6, Documents.DocName7, Documents.DocName8,
Documents.DocName9, Documents.DocName10, Choices.LinkedTo
FROM (Categories RIGHT JOIN (CaseTypes RIGHT JOIN Choices ON
CaseTypes.CaseTypeID = Choices.CasetypeID) ON Categories.CategoryID =
Choices.CategoryID) LEFT JOIN Documents ON Choices.ChoicesID =
Documents.ChoicesID;

Thanks,

gale
 
T

Tonín

I suggest you should use "&" instead of "+" to concatenate the fields

SELECT [Choices].[ChoicesName]&' '&[ChoicesDescription]&'
'&[Documents].[DocName1]&' '&[Documents].[DocName2]&'
'&[Documents].[DocName3]&' '&[Documents].[DocName4]&'
'&[Documents].[DocName5]&' '&[Documents].[DocName6]&'
'&[Documents].[DocName7]&' '&[Documents].[DocName8]&'
'&[Documents].[DocName9]&' '&[Documents].[DocName10] AS searchfield,
Choices.ChoicesDescription, Choices.ChoicesName, CaseTypes.CaseType,
Choices.ChoicesID, Documents.DocName1, Documents.DocName2,
Documents.DocName3, Documents.DocName4, Documents.DocName5,
Documents.DocName6, Documents.DocName7, Documents.DocName8,
Documents.DocName9, Documents.DocName10, Choices.LinkedTo
FROM (Categories RIGHT JOIN (CaseTypes RIGHT JOIN Choices ON
CaseTypes.CaseTypeID = Choices.CasetypeID) ON Categories.CategoryID =
Choices.CategoryID) LEFT JOIN Documents ON Choices.ChoicesID =
Documents.ChoicesID;

Tonín
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top