Jump to content
Sign in to follow this  
MacDigger

Using "OR" for form fields searches

Recommended Posts

Hi!

Here's the description:

I have a library database, and I need to perform search on book titles. The problem is that some books contain articles inside themselves (implemented with related records).

When a search is performed, I need to search for a "title" either in main book info, or inside articles which belong to that book.

Currently, it is implemented so that user can either enter search string into "main title" field, or "related title" field in the search form.

What I'm trying to do is to unify this search, so that in search form I have a single "title" field and the script would find books which either have corresponding "main" titles or "article" titles.

Currently, I'm thinking about having the "main" title search string to be copied into "article" title field before the search is actually performed.

BUT! In this case search is performed using logical "AND". Is there a way to make it use "OR"? I mean "search for books where (main_title="title" OR article_title="title")"

Any suggestions are very welcomed!!

TIA,

Mike

Share this post


Link to post
Share on other sites

You ca do this via a script. Create a global text field (gTitle) and place it on your find layout. Create a script that takes the user to the find layout. The following script would need to be launched via a button after the search text is entered into the gTitle field. This is not exact, but it may get you started:

Enter Find Mode

Set Field (main_title,gTitle)

New Request

Set Field (article_title,gTitle)

Perform Find

Share this post


Link to post
Share on other sites

"AND" searches are performed by entering data into multiple fields of the same Find Request in Find mode. "OR" searches are performed by entering data into multiple Find Requests in Find mode. That's why the scrip step is "New Record/Request/Page", because it acts differently depending upon the mode you are in. When you enter Find mode, you are give a single Find Request to enter data into. If you want additional Find Requests, they can be created from the Requests menu or usin the above script step. If you wish to omit records with a certain entry, you check the "Omit" box in the status bar. Scripting you find might look like:

Enter Find Mode

Set Field (Book Title, "How to Create OR Searches")

New Record/Request/Page

Set Field (Article Title, "How to Create OR Searches")

with an Omit, the script looks like

Enter Find Mode

Toggle Status Area (show) <--- Must show when using Omit step

Set Field (Book Title, "How to OR Searchees")

New Record/Request/Page

Set Field (Article Title, "How to Create OR Searches")

New Record/Request/Page

Set Field (Database Produce, "Microsoft Access")

Omit

This script would find all the book or articles on OR searches, but omit those where the mythical database field is set to Microsoft Access.

-bd

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.