stu2010 Posted August 18, 2008 Posted August 18, 2008 Hi there, reasonably new to FMP i have a database that stores information on equipment and the date it was last tested. At the moment it can store when it was last tested but not anything prior to that. I was just wondering what the simplest solution to keep say the last 20 test dates in the database and be able to bring up a report on the item with all its test dates appearing. Attached is the database in its current form Thanks in advance for your help Stuart. Test_Tag180808.fp7.zip
corn Posted August 18, 2008 Posted August 18, 2008 Repeating fields are not a good solution for what you want. I've modified your file a bit (btw, you should note when a file needs an account/password to open it) to give some examples of what you might do using the related table it looks like you started. Test_Tag_Mod.fp7.zip
stu2010 Posted August 18, 2008 Author Posted August 18, 2008 Thanks for that sorry i forgot about the password.
stu2010 Posted August 18, 2008 Author Posted August 18, 2008 Ok follow up question now, may be the wrong place to ask it but how would i use a script to create new records on my secondary table, basically to display every test in the portal you created.
corn Posted August 18, 2008 Posted August 18, 2008 There are a lot of options for creating records. For the relationship I turned on the option to auto-create records in the Testings table, so you can do it manually. As for scripting it, one basic method is the following: Set Variable [$AssetID; Assets::Asset ID] Go To Layout [Testings] New Record/Request Set Field [Testings::AssetID; $AssetID] Commit Records/Request[No dialog] Within this outline you can set other fields before committing the records. For example, if you want to capture values from a custom dialog you might insert the following before the script steps above. Show Custom Dialog[Title:"Visual"; Message:"Did the item pass a visual inspection?"] Set Variable[$visual; If ( Get ( LastMessageChoice ) = 1; True; False )] You might want to check out some of the online training resources that will explain scripting far better than I can in a single post.
Søren Dyhr Posted August 18, 2008 Posted August 18, 2008 Couldn't both you an Corn provide the rest of us with access to your secrets (via passwords) - what I need to know is if scripting are required at all. If 20 regular test dates exist, or even perhaps regularly spaced dates, should Bruce's unscripted method be all it takes here. --sd
corn Posted August 18, 2008 Posted August 18, 2008 Sorry - I didn't change the File Options either. The account and password to the files are both 'admin' There is no need to script the record creation unless there are other requirements not mentioned. Simply configuring the relationship to allow auto-creation will allow the user to enter multiple testing dates. Even if there are exactly 20 testing dates, evenly spaced or not, I would not advocate using repeating fields for this purpose (the topic of this thread). I don't know what you are referring to by "Bruce's unscripted method" - is this the auto-create relationship chain method he posted a couple of years back? That pattern might be useful when you need to create several records simultaneously but that wasn't indicated here. Even if it were, I propose a scripted approach is likely to be better for simultaneous record creation - you get a lot more control with a lot less graph and table detritus.
Søren Dyhr Posted August 18, 2008 Posted August 18, 2008 is this the auto-create relationship chain method he posted a couple of years back? That pattern might be useful when you need to create several records simultaneously but that wasn't indicated here. It is! - the one using this feature: http://www.databasepros.com/FMPro?-DB=resources.fp5&-lay=cgi&-format=list.html&-FIND=+&resource_id=DBPros000128 ...with a global field on primary side of the matter - But if it works here was next to imposible to establish since a fair amount of guesswork or the use of the bluechillies thingy! I would not advocate using repeating fields for this purpose Neither would you ever find me doing so - I have a fundamental rule only to use repeaters as calculations, never ever for storage! --sd
stu2010 Posted August 18, 2008 Author Posted August 18, 2008 Thanks for all your help, the reason i am using the script is to make it a single click for the records to be updated, several users will be using the UI and updating several records every day. I felt a script would be the easiest way to acheive this... open to any more suggestions though ;)
Al from Manchester Posted October 17, 2008 Posted October 17, 2008 HI, I have a question about repeating fields. I have read that it is not good practice to use them. In my solutions I have 20 sequential events each with a name, an associated template type, ID, event timer etc. I have created 20 sets of fields for these, but now when I want to use logical tests, I have to do it this way: SCRIPT: if( SequenceNumber = 1 ) {event using FieldSet1} Else if ( SequenceNumber = 2 ) {event using FieldSet2} Else if ( SequenceNumber = 3 ) {event using FieldSet3} ...etc etc up to 20. Obviously if i used repetitions, I would be able to instruct it to use field rep 1, then 2 etc using a variable $RepetitionNumber looping through. Should I carry on as I am? Or is this one of the times I can use repetitions? Or is there another way? (I intend to get someone cleverer to me to ultimately reprogramme this into MySQL so want to make the transition as clean as poss) I'd appreciate your thoughts. Al
David Jondreau Posted October 17, 2008 Posted October 17, 2008 In my solutions I have 20 sequential events each with a name, an associated template type, ID, event timer etc. I have created 20 sets of fields for these ... Should I carry on as I am? Or is this one of the times I can use repetitions? Or is there another way? For what you're trying to accomplish, having 20 sets of fields is one of the most inefficient choices you can make. Using repeating fields for this may be even worse. You need to have a table with one record per event, or 20 records per "sequence". You probably need a table for sequences too. Hard to give more advice without more details.
Al from Manchester Posted October 20, 2008 Posted October 20, 2008 Thanks DJ. I was afraid of that. I'll rewrite it.
Søren Dyhr Posted October 20, 2008 Posted October 20, 2008 I'm now back after a holiday, and by the look of it have DJ kept the fort well. I would then add to his comment, that we had a very eye opening thread on this very topic here which gives substance to his suggestion to relational structure: http://fmforums.com/forum/showtopic.php?tid/176396/tp/1/ --sd
Recommended Posts
This topic is 5937 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