November 24, 200817 yr I'm sure I am missing something really simple here so apologies for the level of this question. I have a form which details transactions. I'd like to select all transactions for a particular year. If I go into find mode, it's easy (I enter the year I want and up pop all the related records. However, I want to do it with a button so the user picks the year from a drop-down and then on the button press it finds all related records to that button press. My difficulty is I cannot see how to pass the variable from the year selection to the find script. I can run a find script that pulls back the records where year = 2008. What I cant work out how to do is run a script that pulls back the records where year=yearchoice (where yearchoice is the input field) Help! Cheers TattyDon Edited November 24, 200817 yr by Guest
November 24, 200817 yr Create a global field so that the users can enter in the year. Then you can use a script like this: If [ IsEmpty (gYearinput) ] Show Custom Dialog [ "Please enter in a year" ] Else Set Error Capture On [] Enter Find Mode [] Set Field [ YourDate; Date ( 1; 1; gYearinput ) & "..." & Date ( 12; 31; gYearinput ) ] PerForm Find [] If [ not Get ( FoundCount ) ] Show Custom Dialog [ "No Records Found" ] End If End IF
November 24, 200817 yr Author Thanks for this - I'm a bit confused by the Set field line: Set Field [ YourDate; Date ( 1; 1; gYearinput ) & "..." & Date ( 12; 31; gYearinput ) Whats the 'YourDate' Date bit here and what are the numbers doing here? If it might make it easier, the have a field called 'Year' which pulls the year out of the date field and is therefore the one I want to compare against Cheers JL
November 24, 200817 yr Well if you already have a field that returns the year for each record, then you wont have to look for a date range for the year. You can just change the set Field to: Set Field [ YourDateYEAR; gYearinput ] Another method is: You can create a relationship keyed from the gYearInput field to YourDateYEAR field. Then you can use Go to Related Records instead of using a find at all.
November 24, 200817 yr Can you use */*/gYear rather than the range? Yes. Technically, you can even just set the field with gYear by itself. Since its a date field, FileMaker will recognize that you are looking for a year and fill in the */*/ for you. Enter Find Mode [] Set Field [ YourDate; gYear ] Perform Find []
Create an account or sign in to comment