Jump to content
Server Maintenance This Week. ×

Newbie question re:setfield[]


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

Recommended Posts

Hi all,

Newbie here again.

I created 2 files(.fp7), first file contains records while the second file has empty records.

Second file will be used as a portal

Both Files are related, (file1::pin) have records and i want to copy each record to (file2::pin) whenever i add new records to (file2).

Can I use setfield[] and whats the syntax for this?

Thanks in advance.

Link to comment
Share on other sites

Well no... you would most likely trigger a script in the other file to import the current record your on... theres problems with this though.

Before you go do any of that though, a) why are you replicating data : is there any particular reason you are using 2 files?

Link to comment
Share on other sites

Hi Genx,

I made a new file because file1 contains records already.

The file2 will be used as a portal in file1. I was thinking that if i did it this way I can add new record to file2.

---------------------------------------------

file1----------file2

pin-----------pin-------rank------vessel

10000--------10000-----MS-------RORO

--------------10000-----BS--------NSTY

--------------10000-----WS--------WKMV

----------------------------------------------

file1 contains pin already, while file2 pin is empty

need to connect file1::pin to file2::pin, so I can see the records

of file2-records to file1.

I dont know the script for make new record for just a portal.

Thanks

Edited by Guest
Link to comment
Share on other sites

A) You really don't need 2 files, and in this case, you might be making life more complicated for yourself if you use two files - multiple files were only mandatory prior to FM7, since then, you can have many tables in one file.

Basic relational structure will work as follows:

Main Table:

PrimaryID (or pin in your case, if you can guarrantee uniqueness)

Name

Address

Contact Numbers:

ForeignID

Number

If i wanted to create many contact numbers for one contact, i would relate: Main Table To Contact Numbers by dragging from PrimaryID to ForeignID.

Then, Double click on the newly formed relationship, and on the child side (Contact Numbers) click the option "Allow creation of records in this table based on this relationship".

Then, If you base your main layout on the Main Table, created a portal to the Contact Numbers, based on the relationship we specified, you will get a "ghost record" appear as the bottom row in your portal -- allowing you to add records without duplicating data anywhere.

Confusing? - better to be confused now then sorry later

Link to comment
Share on other sites

Hi again Genx,

I grasp the concept of Primary key and foreign key, but on may Main layout I want to click a button to open up another window of layout and instead of editing the portal at the main menu-portal in main menu will be for viewing only.

On the New Window it will be for editng of the portal, but instead of portal I will use fields.

The user will click a button on the new window and save the data, then the field must be empty again for another data to be entered. So, I need something like (Add record to portal row) to be attached to my Save Button.

And yes your right I'll make another table instead of making another File (what was I thinking!!!).

Thanks a lot

Link to comment
Share on other sites

Well, no, you should "pre-generate" the record, that is... Save the primary key of the current record as a variable.. open your window, go to your secondary table, set the foreign key as the stored variable -- you have a related record e.g.

Set Variable[$key ; MainTable::PrimaryKey]

New Window[]

Go To Layout[some Layout Tacked on to Secondary Table]

Set Field[secondaryTable::ForeignKey ; $key]

Commit record[]

Link to comment
Share on other sites

Wow, that was great.

Now I need a Button to make a new record for the second table only.

I tried to use (New Record/Request) but, all it did was make a new record for all related tables.

Table1::PIN--Table2::KP_PIN---NAME

10001--------10001-----REX-----Click button New rec

>>>>>--------10001------ROY-----Click button

>>>>>--------10001-------SOY-----Click button

and so on................

Thanks again.

Edited by Guest
Link to comment
Share on other sites

e.g. i actually forgot to put new record / request in there.. oops

Set Variable[$key ; MainTable::PrimaryKey]

New Window[]

Go To Layout[some Layout Tacked on to Secondary Table]

New Record / Request[]

Set Field[secondaryTable::ForeignKey ; $key]

Commit record[]

Link to comment
Share on other sites

Well yes, but like i said, you have to be on a layout connected to your secondary table when you perform the new record script step -- otherwise, it generates a new record in your primary table instead.

Link to comment
Share on other sites

Oooh sir genx, isn't that nice.

No i don't really know a lot of good sites for this -- all i can really recommend is the FileMaker manual.

In the end - it just comes to which functions you use - which comes to which functions you know...

Just start - and you'll get better.

Link to comment
Share on other sites

This topic is 6472 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.