Jump to content
Server Maintenance This Week. ×

Using "OR" for form fields searches


This topic is 8315 days old. Please don't post here. Open a new topic instead.

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

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

This topic is 8315 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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