Newbies phil411 Posted February 27, 2005 Newbies Posted February 27, 2005 I am new to the concept of having several Tables in one Database. Previously, when I had to create a record in a (child) related database, I transferred the data using globals, then called a script in the related database, which added the record. Now, this should be easier with multiple Tables in one database I thought. Just call "New record", specifying the Database and insert the data. However, "New record" will create a record in the parent database. You cannot specify the target table - or I simply did not find this function. Well, I can jump to a layout where only the child database is listed, or as an alternative, can jump in a layout, where a portal is visible, then jump to the last record if the portal and then add the data (add some code to freeze the window, stop user-interaction etc. etc. ) But this looks for me more like a workaround then a good solution. Could anyone with experience with FM7 give me a tip to do this a better way ? Thanks.
QuinTech Posted February 27, 2005 Posted February 27, 2005 Hi, Phil, and welcome to the forums! If your relationship is set to allow creation of related records on the right-hand side, then simply setting a value for a field in the related table (other than the key field) should create a new record in the child table. HTH, Jerry
Newbies phil411 Posted February 28, 2005 Author Newbies Posted February 28, 2005 Thanks for you answer QuinTech, That works, but only for one record. If there are already records present in the table, no new record will be created, instead, the current record will be overwritten by the new value. I should have described the problem more exact: I have a text field where you can paste some lines of text. A script then parses the text in that field and filters out unneeded characters and blank lines. The remaining lines should go into the child table. One record per line. I would like to omit switching to a layout where the child table is visible.
QuinTech Posted February 28, 2005 Posted February 28, 2005 I would like to omit switching to a layout where the child table is visible. Hmmm... i don't know if that is possible. I could be wrong, though. I was about to recommend that you insert script steps such as: Go to Field (Field in Portal) Go to Portal Row (Last Row) And then create your new record. This would, indeed, create a new child record without overwriting what you've already got, but given the last line in your post, i suspect you've already tried this and don't like it so much. Maybe you could add a tiny, tiny portal (with fields in 1-point font) to the layout you want people to see, and then hide it somewhere? That way, you could have that last-portal-row functionality without having to switch layouts. If you cover the portal up with a button or a picture, it shouldn't be noticeable. J
Newbies phil411 Posted February 28, 2005 Author Newbies Posted February 28, 2005 Right, I am already doing this - If there is no other way, then ok. I just thought, there could be an easier way. From my experience, if you have to do operations like this with a larger numbers of records, performance will suffer, but I have just begun to try out FM7, maybe it behaves better then older versions, also the Computing Power of a G5 is much better compared to a G3 with OS9 and FM4/5, so you dont notice the slowdown. btw. to delete all related records my workaround is: Loop Go to Field [child::somefield0] exitLoop If [Count (child::somefield0,child::somefield1,child::somefields2) = 0] Delete Portal Row[No dialog] End Loop I suspect, this also is the way do do it. Thanks again for your replies !
QuinTech Posted February 28, 2005 Posted February 28, 2005 Sorry, i can't think of any other way. Maybe someone else knows... As for your related-record deletion, a quicker way might be: Duplicate the parent record Change the key field in the original record Delete the duplicate (making sure the option "Delete related records" is selected in the relationship). This will delete those related records. Back in the original record, change the key field back to what it was originally. J
comment Posted February 28, 2005 Posted February 28, 2005 Of course it's possible - see attached. Creator.fp7.zip
QuinTech Posted February 28, 2005 Posted February 28, 2005 comment, all i'm seeing is the creation of the first related record. What am i missing?
comment Posted March 1, 2005 Posted March 1, 2005 Huh? It creates as many related records as there are lines in Parent::Data.
Newbies phil411 Posted March 1, 2005 Author Newbies Posted March 1, 2005 Works for me too - Nice trick! By first using a non existent key you create a child record. Then change the key to the matching value of the parent. Then repeat until done.
comment Posted March 1, 2005 Posted March 1, 2005 You got it. One caveat though: in a multi-user situation, there's a potential for conflict if two users are calling the script simultaneously. I believe this can be solved by changing the global key calc to something that is user-specific, or Random.
QuinTech Posted March 1, 2005 Posted March 1, 2005 I see. I was trying to enter a value, then click Generate, then enter another value, then click Generate again. Didn't realize you had to enter a multi-line entry. I should've paid attention to the script! J
Newbies yoshi Posted September 6, 2005 Newbies Posted September 6, 2005 Just a quick add-on to this one. Can anyone add any light on to how to do this from one portal to another, rather than one field to another portal?
comment Posted September 6, 2005 Posted September 6, 2005 You may be missing the point here: "this" is NOT using a portal. Just be anywhere where you can (a) create records in the target table via a relationship (in version 7 that could be one or more tables away), and (: have acces to the data you need to pass to the new record - whether it is in the current record, or a related one.
Ginxy33 Posted December 9, 2005 Posted December 9, 2005 I'm new to this Table Occurance stuff. Could you tell me how Parent::gCreator can have a relationship to NewChild::ParentID when gCreator =.5? I geuss I just don't get his concept...
comment Posted December 9, 2005 Posted December 9, 2005 Well, it does have a relationship - it just doesn't have any related records. Until you set a field of the 'non-existing' record - then a new record is created, and it's ParentID has a value 0.5. This is very similar to the last row in a portal. There's no record there, until you start typing into it. That creates a new record.
Recommended Posts
This topic is 6993 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