Search Functions

  • Thread starter Matthew DeAngelis
  • Start date
M

Matthew DeAngelis

Hi,

I have a Contacts database and currently use the 'binocular' search
function built into Access. However, it does not suit all of my needs
and there are some aspects of it I would like to change. Is there a
way to edit the existing search function in a more comprehensive way
than changing it between Fast, General and Start of Field? Is it
possible to create a search function that behaves in the same way
(finding and displaying the record in the complete list; I don't want
to filter it)?

Thanks,
Matt
 
A

Albert D. Kallal

Sure, in place of stuff the results into a "pick list", simply open the form
using the where clause


I used the "like" command to match the first few characters. I would give
that try.

So, make a simple form with a text box. In the after update even, simply
open the main edit form.

Try:

dim strWhere as string

strWhere "LastName like '" & me.txtSearch & "*'"

docmd.OpenForm "mainCusotmer",,,strWhere

The above will thus open direct to the form.

If the search is for a id field, or a number field (ie: not a "text" field),
then you don't need the quotes.

I would try the above. If you want only allow exact matches, then use:

dim strWhere as string

strWhere "LastName = '" & me.txtSearch & "'"

docmd.OpenForm "mainCusotmer",,,strWhere
 
M

Matthew DeAngelis

Albert said:
Sure, in place of stuff the results into a "pick list", simply open
the form using the where clause


I used the "like" command to match the first few characters. I would
give that try.

So, make a simple form with a text box. In the after update even,
simply open the main edit form.

Try:

dim strWhere as string

strWhere "LastName like '" & me.txtSearch & "*'"

docmd.OpenForm "mainCusotmer",,,strWhere

The above will thus open direct to the form.

If the search is for a id field, or a number field (ie: not a "text"
field), then you don't need the quotes.

I would try the above. If you want only allow exact matches, then use:

dim strWhere as string

strWhere "LastName = '" & me.txtSearch & "'"

docmd.OpenForm "mainCusotmer",,,strWhere

--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


Albert,

This works essentially the way I would like it, except that the
Contacts form (the primary edit form) still opens in a filtered view (I
only get the entries that match the field, instead of jumping to the
correct entry within the full display). Is this the case any time a
link criteria is set? How does the code behind the Access search
function focus on a part of the form without filtering it?


Thanks,
Matt
 

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