TattyDon Posted November 24, 2008 Posted November 24, 2008 (edited) 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, 2008 by Guest
mr_vodka Posted November 24, 2008 Posted November 24, 2008 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
TattyDon Posted November 24, 2008 Author Posted November 24, 2008 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
mr_vodka Posted November 24, 2008 Posted November 24, 2008 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.
bcooney Posted November 24, 2008 Posted November 24, 2008 Can you use */*/gYear rather than the range?
mr_vodka Posted November 24, 2008 Posted November 24, 2008 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 []
Recommended Posts
This topic is 5842 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