I would like to set the initial value of a fo...

expressions
(Kevin Biggar) #1

I would like to set the initial value of a form to be the previously entered value+1.

The column is called [Trainingplanday]. So I’m putting [Trainingplanday]+1 in this columns ‘Initial Value’ field (see image).

I know this expression works because it works in other columns. But it won’t work in it’s own column. I should say that this column type is ‘Ref’. I expect that is what is stopping it. Is there any work around?

(Aleksi Alkio) #2

What is the error message or behavior you are seeing with it?

(Kevin Biggar) #3

It just defaults to the normal drop down list

(Aleksi Alkio) #4

If you don’t have that date in that ref column (values for the dropdown), it won’t show it as initial value. Can that be the reason?

(Kevin Biggar) #5

I don’t quite understand what you’re saying but I don’t think so. [Trainingplanday] is a number (currently between 1-5), which represents the day of my training plan. Oddly, I can put any other column name as the Initial value for [Trainingplanday] and it works just fine. It just seems to have a problem referring to itself. Maybe when you’ve set the column to ‘Ref’ it stops being able to read it’s own value (because it’s now linked to a column in another table?)

(Aleksi Alkio) #6

When you said “previously entered value”, do you mean another record than this one?

(Kevin Biggar) #7

Hi Aleksi, I think you are onto something with your question. What I want to do - at the most simple level - is use the form to insert a number, and then the next time I use the form for that number to be the ‘initial value’ of the same field. So if I enter ‘5’, then the next time I use the form it should have 5 in that field. If I enter 6, it should be 6. What happens at the moment is that ‘initial value’ field keeps showing ‘5’. It’s like it puts the new row at the bottom of the table but ‘reads’ the tops row. How can I make it read the newest row?

(Aleksi Alkio) #8

First you would need to read the last record’s key column’s value with the MAXROW expression. Then you could read the last trainingplanday value with the formula [MaxRowColumn].[TrainingPlanDay].

(Kevin Biggar) #9

Yes! 'That’s exactly what I needed. For anyone following this thread there is a demo app called ‘Most recent value’ that demos exactly what I was trying to do using ‘Maxrow’. Thanks very much for persevering Aleksi!