troypatrick Posted November 9, 2000 Posted November 9, 2000 I was wondering if anyone could help me with a script. I would like this script to open another file with information that is assocaited with this file and if there is no info. related I would like a field from the original copied into the first field of the second file. This would allow me to enter data that is related to this file or view the inforamtion that had been previously entered. I have a relationship set up but I would like to have the field copied over automatically if there is a new record to be entered. I hope this is clear.
Chuck Posted November 9, 2000 Posted November 9, 2000 Let me see if I understand you. You have two files that are related. You want to go from file 1 to the related record in file 2 if such a record exists. If not, you want to create a related record? Is that right? If so, here's what you do. I'm assuming the the relationship is called "file2|file1ID" (with a relationship based on file1's ID field in both files), and that file2 has an ID field called file2ID. If [ not IsValid ( file2|file1ID::file2ID ) ] Set Field [ file2|file1ID::file1ID, file1ID ] End If Go to Related Record [ file2|file1ID ] This checks to see if there is a valid record in file 2 that is related to file 1. If there isn't, the way relationships work will create one with the Set Field statement. Once it is created, or if it already existed, then the script will go to the related record. Chuck
troypatrick Posted November 10, 2000 Author Posted November 10, 2000 thanks for the help with the copying fields this afternoon. I think I just about have the problem solved. Do I need do define 2 relationships each pointing to file one and two Ex. file2|file1ID::file2ID file2|file1ID::file1ID If this is the case - Can I define this second relationship when I'm writing the script for it in the other file. For example when I click the button I would like it to perform the script that I mentioned this morning. Thanks for all your help - it is greatly appreciated quote: Originally posted by Chuck: Let me see if I understand you. You have two files that are related. You want to go from file 1 to the related record in file 2 if such a record exists. If not, you want to create a related record? Is that right? If so, here's what you do. I'm assuming the the relationship is called "file2|file1ID" (with a relationship based on file1's ID field in both files), and that file2 has an ID field called file2ID. If [ not IsValid ( file2|file1ID::file2ID ) ] Set Field [ file2|file1ID::file1ID, file1ID ] End If Go to Related Record [ file2|file1ID ] This checks to see if there is a valid record in file 2 that is related to file 1. If there isn't, the way relationships work will create one with the Set Field statement. Once it is created, or if it already existed, then the script will go to the related record. Chuck
Chuck Posted November 10, 2000 Posted November 10, 2000 You only need one relationship to make this work. When I write a relationship like file2|file1ID::file1ID, I mean that the relationship exists in file1. It is related to file2 via file1ID=::file1ID. So I'm referring to the file1ID field in file2 using the relationship file2|file1ID. Create a relationship to file2 and have the file1ID as the match field on both sides. These two strings of text: file2|file1ID::file2ID file2|file1ID::file1ID refer to the same relationship, but to different fields in the related file. The relationship name is file2|file1ID. I use this naming convention so that if something goes wrong, I know what file the relationship is to (file2) and I know what the match field in the related file is (file1ID). The field referred to in the first line is file2ID in the file file2. The field referred to in the second line is field1ID in the file file2. Does that clear things up? Chuck
troypatrick Posted November 10, 2000 Author Posted November 10, 2000 Hi again, My major problem seems that I can't set up 2 relationships on the ID field - one for ID1 &ID2
Chuck Posted November 10, 2000 Posted November 10, 2000 quote: Originally posted by troypatrick: Hi again, My major problem seems that I can't set up 2 relationships on the ID field - one for ID1 &ID2 You don't need two relationships, you only need a single relationship from one file to the other file based on the unique ID field in the first file. The second file needs to have a field that can have the unique ID of whatever record in the first file it is related to. Chuck
troypatrick Posted November 10, 2000 Author Posted November 10, 2000 Maybe I have something set up wrong besides the relationship. Do you mind if I forward the file to you so you can see what I'm looking at. Cheers
troypatrick Posted November 10, 2000 Author Posted November 10, 2000 Clarification When I refer to going to file 2 from file 1 - they are seperate data bases. One is the main data base while the other is a branch of the main that has an ID number in common. That is the only field that they have in common, Does this make a difference. Cheers
troypatrick Posted November 15, 2000 Author Posted November 15, 2000 Thanks for all your help Chuck. It works great Cheers
Recommended Posts
This topic is 9026 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