Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Trouble Making Check Box Work

Featured Replies

Dear FileMakers,

 

I'm trying to get a checkbox menu to work.

Please see the example. There are 10 trains. When I select train 5, the find brings up train 5's data. Then, when I also select train 6, it finds train 56's data.

 

There is no train 56 - I'm trying to bring up results for train 5 OR train 6.

 

Seems it should be very simple, but it's had me going around in circles. If someone could the attached to work, and provide a explanation of how you did it I'd be so grateful!

 

Ben

 

CheckBox.zip

It sound like you need a "New Record Request for your  search.

 

Enter Find mode

find 5

New Record Request

find 6

perform find

 

Lee

  • Author

Thanks (again!) for the reply Lee,

 

Regret that I don't understand how to hook that piece of code up to the checkbox. To be clear, the user should be able to search for x OR y OR z, with x y and z being defined via the 1>10 checkbox range.

 

Am I missing something here?

 

Ben

Ok, I looked at your file and I think I understand what your dilemma is.

 

Will you want to Find for only one at a time, or will you want to Find multiples?

  • Author

I'm looking to be able to find multiples


Thanks,

 

Ben

Ben,

Jumping in one this, if you don't mind. Your structure will hit a wall soon. How many "train" records will there be? Do you intend to keep updating the value list to include all the train records?

 

Why not tell us the real-world problem you're trying to solve. Simply teaching the user how to Find, Enter Criteria, New Request, Enter More Criteria, Perform Find will provide them with the ability to search the database without developer involvement.

 

-Barbara

  • Author

Hi Barbra,

 

I work for a company providing internet access to high-speed rail. There are 25 trains in this particular fleet.

Everyday the trains run their routes, and we collect lots of data from various sources regarding the performance of our systems.

 

Right now I can search one train, across a date range, and see how it's performed over a period - which is very useful.

 

But I can't search the whole fleet on one day. Or maybe take a look at a few trains of particular interest.

 

For my own education, how would you input that search?

 

For example, I know that 5...10 would search trains 5 through 10. How would I request trains 5 or 10?

 

Thanks,

 

Ben

OR searches are done using New Request.

I showed how that is done in my post above (#2). Maybe I should have also suggested that Ben go through the tutorials and user guides, and start with Finding records as it is one of the primary reasons to use a database in the first place.

  • Author

Ok, I know how to new find requests to provide the OR function, and I know how to find records. I've got those basics down now.

 

I need to make the interface perform as the user would expect it to and minimise their learning curve - and I think they'll already understand the checkbox set to represent an OR search, without training them in find requests.

 

Isn't that the purpose the checkbox is meant to serve? If not, what does it do?

Please read the manual or go through the tutorials. I don't want to put you off, but you can't learn FM well this way.

 

Sometimes checkboxes are used this way, but typically they are used to store multiple values in one field. Checkboxes actually aren't a logical OR, but rather a logical AND.

I need to make the interface perform as the user would expect it to and minimise their learning curve - and I think they'll already understand the checkbox set to represent an OR search, without training them in find requests.

 

Your users do not need to understand find requests - it's your job to do the work for them. For example, you could give them a global checkbox field and a "Find" button. The script would then go and create a separate find request for each checked item.

 

Note that you can also use a relationship to find matching records. Matching a checkbox to a field makes all records containing any checked item related - and you can then use the Go to Related Record[] script step to create a found set of them.

  • Author
For example, you could give them a global checkbox field and a "Find" button. The script would then go and create a separate find request for each checked item.

 

Right - that's exactly what I'm trying to achieve - in the file I provided there is a global check box field, and a find button, set to perform the following script:

 

Enter Find Mode []

Set Field [CheckBox::Train; CheckBox::Global Train]

Perform Find []

 

The outcome of this is:

Selecting Train 5 brings up results for 5

Selecting Train 6 brings up results for 6

Selecting 5 and 6 brings up results for 56 - when I'm looking for results from 5 or 6

 

Ben

That's because your script does not create a separate find request for each checked item. Try instead:

 

Enter Find Mode []

Loop

Set Field [ CheckBox::Train ; GetValue ( CheckBox::Global Train ; Get ( RecordNumber ) ) ]

Exit Loop If [ Get ( RequestCount ) ≥ ValueCount ( CheckBox::Global Train ) ]

New Record/Request

End Loop

Perform Find []

 

 

---

Note also that if CheckBox::Train is a Text field, searching for "5" will find both "5" and "56" (words starting with "5"). But judging from your result it is a Number field, so it shouldn't be a problem. Just make sure that CheckBox::Global Train is a Text field, because it needs to hold multiple values separated by a carriage return.

Edited by comment

  • Author

That is perfect, exactly what I was looking for - the script works great!

 

Just make sure that CheckBox::Global Train is a Text field, because it needs to hold multiple values separated by a carriage return.

 

This is also extremely useful - I would not have known that.

 

Thanks for your help,

 

Ben

  • Author

Ok - sorry, one more question

 

I also have a date filter, enabling me to search between dates.

The script I was using for that was:

 

Set Field [Datefield; GlobalStartDate & "..." & GlobalEndDate]

 

However, I can't make it work with the checkbox code Comment provided.

 

Could someone explain how I should work it into the script, so I can search for multiple trains across selected dates?

 

Thanks!

Make these two changes:

 

1. Set the Datefield immediately after entering Find mode, before starting the loop;

2. Use Duplicate Record/Request instead of New Record/Request.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.