Jump to content

Automatic number when importing


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

Recommended Posts

I have a field that is a counter for a specific persons records in a file. This works fine so long you manualy create new records. The problem is when I import records then the value don't get any bigger then one (1). To count a persons records I use a self relationship and the following calculation in the field.

code:


If( fieldname <> "";

If( Count(Selfrelationship::fieldname <> "";

Count(Selfrelationship::fieldname)+1;"1");"")

It counts the time a record with fieldname exists and put that + 1 in the counter field.

Is there some smart way to solve a problem like this? At second thought the solvation dosen't have to be smart so long it works wink.gif

//Henkan

Link to comment
Share on other sites

Alternatively, you could create a calculated numerical field for each record where the result is always "1" and use the Sum function instead (ie. "Sum(selfrelationship::C_Constant)".

By using this method, you never have to manually increase any field and even records that are imported will have a value of "1".

Link to comment
Share on other sites

quote:

The calculation is your problem. Change your entire calculation to:

Count(selfrelationship::fieldname)


If I use this calculation the first record for this person will have no value. That will mess things up when I realy want a value in this field and has set the field to "Not empty".

I haven't tried the other suggestion yet but although it seems to solve the problem with no value in the field will the second post realy get 2 as value? Or have I got it wrong that the Sum like Count only sees records that already exists and not the one I' creating? Maybe if I take Sum(selfrelationship::C_Constant) + 1, but I tried that with Count and it didn't work. I have to try that out later today. I'm happy for all suggestions.

//Henkan

Link to comment
Share on other sites

Rob thanks for your answer.

I tested your calculation but I don't get a value into the field. It is empty after the import. What have I done wrong??? crazy.gif

What I did was created a field, Calc1, which I equeld with 1. I set the calculation in my counterfield, Counter, to Sum(selfrelationship::Calc1). The selfrelationship is based on my foreign key.

Link to comment
Share on other sites

On the other hand it didn't work like I thought it would. I can't store the value and FM says something about the reason could be because it referes to a relation field.

This shouldn't be that hard to do, is it me that hasn't got the hold om FM yet? It proberly is

Link to comment
Share on other sites

This topic is 7138 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
 Share

×
×
  • Create New...

Important Information

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