benmayo Posted January 2, 2013 Posted January 2, 2013 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
Lee Smith Posted January 2, 2013 Posted January 2, 2013 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
benmayo Posted January 2, 2013 Author Posted January 2, 2013 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
Lee Smith Posted January 2, 2013 Posted January 2, 2013 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?
benmayo Posted January 3, 2013 Author Posted January 3, 2013 I'm looking to be able to find multiples Thanks, Ben
bcooney Posted January 3, 2013 Posted January 3, 2013 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
benmayo Posted January 3, 2013 Author Posted January 3, 2013 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
Lee Smith Posted January 4, 2013 Posted January 4, 2013 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.
benmayo Posted January 4, 2013 Author Posted January 4, 2013 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?
bcooney Posted January 4, 2013 Posted January 4, 2013 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.
comment Posted January 4, 2013 Posted January 4, 2013 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.
benmayo Posted January 4, 2013 Author Posted January 4, 2013 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
comment Posted January 4, 2013 Posted January 4, 2013 (edited) 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 January 4, 2013 by comment
benmayo Posted January 4, 2013 Author Posted January 4, 2013 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
benmayo Posted January 4, 2013 Author Posted January 4, 2013 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!
comment Posted January 4, 2013 Posted January 4, 2013 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.
Recommended Posts
This topic is 4587 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 accountSign in
Already have an account? Sign in here.
Sign In Now