Search part of name field

C

CSCS

Hi Guys!

I'm working on this database in which I have 2 forms:

one form has personal information (PersonalInfo)
and the other one is a search form (Search)

In the search form I have a field in which I want to type any part o
the Name field in PersonalInfo form and I want to retrieve all th
records that have this part of the name.

Here is what I tried:

In the PersonalInfo form, I want to the criteria of the NameField an
typed the following:

Like %[Forms]![Search]![SearchField]%

but it didn't work.

Any help will be very much appreciated.

Regards,
CS
 
D

Dodo

CSCS said:
Hi Guys!

I'm working on this database in which I have 2 forms:

one form has personal information (PersonalInfo)
and the other one is a search form (Search)

In the search form I have a field in which I want to type any part of
the Name field in PersonalInfo form and I want to retrieve all the
records that have this part of the name.

Here is what I tried:

In the PersonalInfo form, I want to the criteria of the NameField and
typed the following:

Like %[Forms]![Search]![SearchField]%

but it didn't work.

Any help will be very much appreciated.

Regards,
CS.

I would do it by putting in the query criteria for that field:

like "*" & [Part of name?] & "*"

The advantage is that when no text is entered, you will get all records.
The disadvantage is that you will only be asked for criteria when the form
is opened.
 
J

John Vinson

In the PersonalInfo form, I want to the criteria of the NameField and
typed the following:

Like %[Forms]![Search]![SearchField]%

% is the wildcard for SQL/Server or ADO recordsets; the wildcard for
an Access JET database is *.

Try

LIKE "*" & [Forms]![Search]![SearchField] & "*"

to literally concatenate the wildcards onto the parameter value.

John W. Vinson[MVP]
 
Top