Jump to content

copying fields


This topic is 8585 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 8585 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.