Extra lines appearing in Query builder!

Steve78

Registered User.
Local time
Today, 12:50
Joined
Feb 24, 2006
Messages
13
Can anyone help please?

I have a search form that passes 4 parameterers to a query.
In the query builder it reads:

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"
>=[FORMS].[frmCourseSearch].[txtStartDate]
<=[FORMS].[frmCourseSearch].[txtEndDate]
[FORMS].[frmCourseSearch].[txtCourseID]

This works fine. But I also want it to search on only 1 or 2 parameters and set the rest to Null so I have used this statement for each one.

Like [FORMS].[frmCourseSearch].[txtCourse] & "*" OR Like [FORMS].[frmCourseSearch].[txtCourse] & "*" Is Null

This again works ok and I can search on any parameter. However, every time I enter data into the search form and run the query it repeats the query string in the query builder. i.e

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

etc...

It does this with all 4 parameters and it's starting to look very messy. The SQL view is the same with a new repeated line added each time I run the query.

How do I stop this happening?

Thanks in advance.
 
Last edited:
Try GROUP BY to filter the result.

I always use the query tool in access to create such a query before I try to write it in code

Steve78 said:
Can anyone help please?

I have a search form that passes 4 parameterers to a query.
In the query builder it reads:

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"
>=[FORMS].[frmCourseSearch].[txtStartDate]
<=[FORMS].[frmCourseSearch].[txtEndDate]
[FORMS].[frmCourseSearch].[txtCourseID]

This works fine. But I also want it to search on only 1 or 2 parameters and set the rest to Null so I have used this statement for each one.

Like [FORMS].[frmCourseSearch].[txtCourse] & "*" OR Like [FORMS].[frmCourseSearch].[txtCourse] & "*" Is Null

This again works ok and I can search on any parameter. However, in the query builder every time I enter data into the search form and run the query it repeats the query string in the query builder. i.e

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

Like [FORMS].[frmCourseSearch].[txtCourse] & "*"

etc...

It does this with all 4 parameters and is starting to look very messy. The SQL view is the same with a new repeated line added each time I run the query.

How do I stop this happening?

Thanks in advance.
 

Users who are viewing this thread

Back
Top Bottom