Newbies Janet Posted February 1, 2002 Newbies Posted February 1, 2002 I am creating a set of databases to track our clients. Main has the client's contact information. History has a running dialog of past contacts with the client. The only 2 fields that are common between the databases are Cust Name and Cust ID. I want to be able to enter a new client record in Main and have a blank record automatically created in History. I also want the Cust Name and Cust ID field values to be propagated into History from Main. I defined a relationship between the databases using a "dummy" field, which finally got rid of my circular definition problem. I defined both fields as Calculations and tried both the SetField and (when I upgraded to 5.5) GetField options. The script generates a new record, but the Cust Name and Cust ID fields in the new record are blank. I'd appreciate suggestions on how to do this. Thanks
LiveOak Posted February 1, 2002 Posted February 1, 2002 Create a relationship from Main to History (created in Main) based upon the Cust ID field and check "allow creation of related records". History doesn't need a Customer Name field, this can be displayed by creating a relationship from History to Main (created in History) and displaying Customer Name as a related field. If you display the History records using a portal in Main, a new record in History will be created by typing history information into the blank line displayed as the last line in the portal (no scripts required). -bd
Vaughan Posted February 1, 2002 Posted February 1, 2002 If the CustId field is unique and invariant, use this for the relationship in both sides. Make the relationship in the Customer file linking to the History file. In the relationsip, set the "allow creation of related records" option. On a layout in the main (customer) database, create a portal with the related hostory fields in it. Notice there is a blank row: entering in to a hoistory will automatically create a new related record in the History database. No need for a script (or whatever) to create new records.
Newbies Janet Posted February 1, 2002 Author Newbies Posted February 1, 2002 Thanks for the advice. I didn't really want to use a portal in the main database. I kind of wanted to go to the history file with a nice blank record to enter contact information into. Here's where I am at this point. I enter a record in Main (Cust ABC / auto-generated Cust ID of 1010). I then invoke a remote script in History, which enters Browse mode and Adds new record. New record displays blank Customer Name and Cust ID field. The problem is that in the script I'm attempting to insert the Cust ID value from the Cust ID field in Main (using the Set Field scripting function), but it doesn't work. If I manually type the Cust ID in History, then Customer Name displays (from Main) as it should. Contact update field is blank and cursor is positioned there for input, which is what I wanted to happend AFTER the two other fields were auto-filled in. Ultimately the 2 databases will be a one-to-many situation. Main: ABC1010 --> History: ABC1010-01, ABC1010-02, ABC1010-03, etc (one record for each contact 'event'). I liked the idea of 2 clean databases, since the data in them is so different, and the History file will quickly grow to be very large, as we enter contact updates. If I can get the Cust ID field to display, everything else should work fine, since it all works once I manually enter the Cust ID value. So if you can help me figure out why this one action isn't happening that would be great. Here are some specifics: Main: Customer Name = (Text, Indexed) AND Cust ID = (Number, Indexed, Auto enter Serial, Can't modify). History: Customer Name = (Calculation, Unstored, Main:Customer Name) AND Cust ID = (Number, Indexed). Relationship is defined from Main to History on the Cust ID field, allowing for the creation of related records. I also had to set a relationship the other direction (from History to Main) so I could see Main in order to define the Set Field for Customer Name. Again, I appreciate any additional advice you can offer.
Vaughan Posted February 1, 2002 Posted February 1, 2002 Probably the easiest way to create a new related record the way you want is to make a "match all records" relationship between the databases. easiest way is to have a field in both databases with the value 1 in them. In the main database create a global field. When you want to creat a new related record, run a script in the main db that sets the current master key value into the global field, then run a script in the related database that creates a new record, sets the local key field to the related global field, then refreshes the window and brings the window to front.
Recommended Posts
This topic is 8402 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