Mitchell Design Posted December 22, 2001 Posted December 22, 2001 Hi all, My first post. Have already gleened much from the forums. Many thanks to all the masters. Here's my One to Many "dilema"... I have 2 dbs - "Master Item" (One) and "Component" (Many). "MI" has a unique serial number assigned to each new record. Through a script between "MI" & "C", a user increments a "component number" field by one for each new component created (this number is held in the Master Item record), creates a new record in "C" that sets the serial number from one global, and sets the new component number from another global. The two are read into "C" and the relationship is made (i.e. - P4100-1) Here's the fun... From "MI", I need to be able to let my users, at *only* the click of a button, duplicate the current "MI" record and related "C" records. The duplicate assigns a new serial number to the "MI" record, but how do I duplicate the related records in "C" and get my new serial number into the necessary field to make the relationship to the new Master record work? This is all to save tremendous amounts of data entry as many items can carry duplicate information. I'm sure there is a very simple solution to this, but just can't seem to find it yet. Many thanks in advance for any help. Jim Mitchell [email protected] [ December 21, 2001: Message edited by: Jim Mitchell ]
danjacoby Posted December 23, 2001 Posted December 23, 2001 Not sure about the whole serial number thing you have going -- it sounds like a lot of extra work. Nevertheless... It sounds like you want to duplicate one Master record and all of its related records so that the duplicated related records now relate to the duplicate of the Master record. If so, I recommend the following steps: 2: Create a script in the Master file that: a) shows all records, : omits the current record (Omit Record), c) shows the omitted record (Show Omitted), d) copies the key field (the one used to relate the "C" file records) in the Master file, e) performs an External Script (see step 1 below), f) duplicates the current record and sets the key field to the new serial number. 1: Create a script in the "C" file that: a) finds all related records (Enter Find Mode, Paste [into the key field], Perform Find), duplicates all found records (use a loop), putting the new relationship number (serial number???) into the key field (use the "Set Field" command) c) closes the file. HTH, Dan
Mitchell Design Posted January 2, 2002 Author Posted January 2, 2002 Dan, Thanks for the reply & sorry to take so long to get back to you. You know how the holidays can be. Your advice was a great starting point, but I had some troubles with the whole loop thing. In fact, I was trying to avoid it altogether, since I had never found loops very reliable ... until today. I'd never considered using a global as a loop counter until I saw the "Go to record by field value" option. (duh) Here's the solution I came up with... In my Master Item.fp5 db: Show All Records Omit Record Show Omitted Duplicate Record/Request - had to do this here to get the new serial assigned Set Field ("global_serial", "serial") Omit Record - This is to go back to the original record Go to Related Record (Show, "Component") Perform Script (Sub-scripts, External: "Component.fp5") In my Component.fp5 db: Created 2 new fields: loopCount & recordCount Go to Record/Request/Page (First) - just to be safe Set Field ("loopCount","1") Set Field ("recordCount", "Status(CurrentFoundCount)") Loop Duplicate Record/Request Set Field ("serial","CompToMaster::global_serial") Omit Record Set Field ("loopCount", "loopCount+1") Go to Record/Request/Page ("loopCount") Exit Loop If ("loopCount = recordCount + 1") - wouldn't work otherwise End Loop Show Omitted Go to Record/Request/Page (Last) Go to Related Record (Show, "CompToMaster") Set Field ["CompToMaster::global_serial",
Recommended Posts
This topic is 8417 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