Hi, apologies for what I'm sure is a ridiculously basic question. I'm also not exactly sure what terminology to use to ask this, so I hope this makes sense.
I want to write a function to look at all the records in a form and update them if they meet certain criteria. I've attached the function to a button on a page and it's running, but it isn't doing anything. Here is what I've written:
- void InputProjectStartandEnd()
- {
- info "running";
- //START date
- for each r in Projects
- {
- if(r.Project_Start_Date = null)
- {
- start = r.Schedule.Start_Date;
- Project_Start_Date = start;
- }
- }
- //END date
- for each rec in Projects
- {
- if(rec.Project_End_Date = null)
- {
- end = rec.Schedule.End_Date;
- Project_End_Date = end;
- }
- }
- }
It's supposed to iterate through each record in Projects, checking whether Project_Start_Date is null. If so, it looks in the record's Schedule subform, gets the Start.Date and inputs it in the Project_Start_Date field.
Then it's supposed to do the equivalent with the Project_End_Date.
(Note: in theory, each Projects record could have multiple records in the Schedules subform, but I know that these records only have one Schedule record each, so I think the code should therefore just retrieve the single start/end date it finds.)
I've tried various things to debug the code, such as telling it to input exact dates or look for certain dates (rather than null values) but as far as I can tell it's just never getting to the point of accessing the Projects records.
Note: the 'info' line is working (I just put that in to check the function was actually being called).
Again, I'm sorry for what is probably a really trivial question, but can anyone tell me where I'm going wrong?
Thanks!