Jump to content

Dynamic relationship or something ..


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

Recommended Posts

I'm creating a training diary solution. I have a layout showing statistics for the training. It contains maybe 30 fields looking like this:

sum(Relation1::sport1)

next field

sum(Relation1::sport2)

and so on .....

The relation looks like this:

field 1

(activityuser & " " & year(activitydate)

field 2

(globloginuser & " " & globyear)

On the layout the user can choose year number. But I want the user to be able to choose if he shall get stats from a year, month, week or between two dates just checking a checkbox and filling a globalfield. All on the same layout. Can I get the relation to change depending on what the user chooses?

Or will I have to write all the stats calcs like this:

Case(

checkboxyear=1;sum(relation1::sport1);

checkboxmonth=1;sum(relation2::sport1);

and so on ...

Hope I'm clear enough ..

Link to comment
Share on other sites

I think you may be able to use GetField( ) for this one. But I'm not really sure what your structure is. Could you post zipped/stuffed clones of the relevant files?

Link to comment
Share on other sites

To get stats from "a year, month, week or between two dates" means matching keys in the parent file with different keys in the child file. I don't think this can be done with one relationship. Let's look at the data for the keys:

Parent file's key User_Week (when week chosen=23 and current user=hsimpson):

hsimpson 23

Child file's key User_Week

bsimpson 1

hsimpson 1

msimpson 1

bsimpson 2

hsimpson 2

...

bsimpson 23

msimpson 23

hsimpson 23

bsimpson 23

...

Now the parent file's key for User_Year:

hsimpson 2003

Child file's key User_Year

bsimpson 2003

hsimpson 2003

msimpson 2003

bsimpson 2003

hsimpson 2003

...

bsimpson 2003

msimpson 2003

hsimpson 2003

bsimpson 2003

...

The key in the parent file is not hard to calculate based on whatever is "checked", but combining data for the match field is another matter. Hmm...maybe if the match field contains each of the possible matching criteria, and it's clear which is which:

User_Match = activity_user & " week" & weekofyear(activitydate) & "[par]" &

activity_user & " month" & month(activitydate) & "[par]" &

activity_user & " year" & year(activitydate)

And the key in the parent file would be something like

activity_user &

case(gRadioChoice = "Week"," week",

gRadioChoice = "Month"," month",

gRadioChoice = "year"," year") &

gUserInput

Just might work. The date range thing is another matter.

Link to comment
Share on other sites

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