Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing The Next Record 1

Status
Not open for further replies.

thanh1800

Technical User
Aug 2, 2006
43
0
0
AU
Okay I have solved many problems

I now need to reference the previous record to make a calculation. A dummy database is shown below.

day
9 <<<(first record)
10
11
12

The code for this would look something like this.

--code--

if (previous_record != null or does not exist){
current_record = previous_record + 1
}else{
current_record = 9
}

--end code--

summary (need to know how to)
- referencing previous and next record
- detect nulls or undefined or non-existing without crashes

Any solution or designs are welcomed
 
What is the relationship between the records in a given range ?
 
well all i want to do is be able to populate a field base on a math.

so the relationship is

the current record(say R5) is eqaul to what ever the previous record is plus one.

the next record(say R6) is equal to R5 plus one


another possible solution could be

--code--

current_record = current_record_index*1 + 9

--end code--

in this case we would use an automatic index and then adding a constant(9) modifier
and the (*1) can make the increment of one or 2(*2)

but how ever it goes my aim is to automatically populate these field with data that is decided by math or


--code--
if (previous_record != null or does not exist){
current_record = previous_record + a
}else{
current_record = a
}

--end code--

which will result in

day
a
aa
aaa
aaaa
 
The relationship question was to know if there is already a selfjoin relationship in the file...

One way to go is using a lookup.
You need a selfjoin relationship between Serial::previousSerial

PreviousSerial = Serial - 1

To find the previous value you need to lookup, based upon the relationship, but check the 'copy next lower value'.

So, 5 fields
addValue, is whatever you want to add
previousValue_nlu, is the lookup
value_cn = previousValue_nlu + addValue
serial_aen, autoenter serial number
previousSerial_cn = serial_aen - 1

This will increment at recordcreation.
If you want it in a given range, you will have to script your steps.

Keep in mind that you can not mix the operators, (+) is for numbers, (&) is for text.
If you want a mix of this you will have to use the proper functions.
 
from what i can see this works in terms of populating the database on creation

but if i say delete a record in the middle of my database i will require the rest of my record to change it's content to suit the new database.

for example

day
9
10 <<< delete
11
12
13

---
you will get
day
9
11
12
13

i want
day
9
10
11
12
 
>> from what i can see this works in terms of populating the database on creation

That's indeed what I mentioned in my post: This will increment at recordcreation.

If you delete a record, there several ways to go.
Depend on your structure and what you want to do. Not knowing the structure or the purpose of what you want to achieve:
Use the Replace Field Contents script step - Replace with serial numbers

An other way could be to search for missing serials and let FileMaker create the next records with the missing serial first, untill there are no missing serials anymore, and then go on creating reords with 'new' serials.
But again it depends...
 
well my calculation is a bit complicated but it is coming along

I am creating a custom calender which because it is using math can go to the year 9999 or what ever.

over all it is still coming along
but an important thing i need to know is how can i detect non-existing field or null fields

and getting the current date which needs to be renewed at least once everyday(schedule get date)
 
okay I have had a look at it
but i think i can make a better calender

can you tell me how to detect decimal places

3/2 = 1.5 <<< detected
2/1 = 2 <<< pass
9/3 = 3 <<< pass
9/8 = 1.125 <<< detected

mine will be base on math rather then data
meaning when you select a certain month eg. may 2006 the math tell you what day the 1st(mon)-31st(wed) will be. rather then create days and month before hand then using the input to find the days to dsiplay
 
Decimals:

Use a validation by calculation, strict, do not allow override validation, with message:
Truncate(Number; 2) = Number
or put it in a validation field.

First day of Month : Date ( Month ( DateField ); 1; Year ( DateField ))

Last day of Month : Date ( Month ( DateField ) + 1; 1; Year ( DateField )) - 1

and noe that we are at it, first day of week:
DateField - (Mod ( DateField - Date ( 1; 3; 1904); 7))
 
wow thanks

i was however half way through my calculation though

but this works too

now knowing how ingnore decimal is my aim

example

1.1
1.145
1.6
1.9999
1.23434234324
1.867755

will all result in 1
like i want to just ignore the any number behind the decimal and no rounding what so ever
 
Make for the always returning calculations a Custom Function.

You will see that for some calculation you will need a recursive calculation.
Make also a Custom Function for those.
It will save you a lot of time in coding.
 
okay thanks JeanW

I my task for this thread is done
there fore this thread is now considered closed
 
To come back on your calendar...

I don't see why you need several records.
I have a calendar with 4 fields, 1 record and 1 script.
It covers the whole possible native FileMaker daterange, going from year 1 to 3000.....even 4000, what is the limit on datecontrol within FileMaker.

I wonder how you will manage to check for accuracy beyond that limit....
 
Well JeanW I am working on many things and well the calender is being used not only for dates but as link to chedules and many things
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top