Hi,
I am quite new to Access and have a problem I hope someone can help me with.
I have a main form called frm_SAMPLE and in this form I have added a subform called frm_JM_subform. The subform is a continuous form linked through a relationship sample_id <> sample_id. It is a one-to-many relationship, eg. the subform frm_JM_subform contains many records for every record in frm_SAMPLE. The subform frm_JM_subform is based on table tbl_JM and the main form based on a table called tbl_SAMPLES.
I wish to count the number of records in the subform and through a calculation add an incremental index number to every record in the subform, something like the example below:
Nr. Field 1: Field 2:
1 Value 1 Value 2
2 Value 1 Value 2
etc.
The incremental number in the first row is of course not the key as the relationship will decide which records show depending on which record is active in the main form. It is this number I am trying to calculate. Is is this incremental number I wish to show in the subform.
As an example I have watched a youtube instruction video almost solving my problem.
My calculation looks like this:
=DCount("*";"tbl_JM";"JM_id <=" & [JM_id])
The calculation works but the values it returns are based on the whole table (tbl_JM) and not the relevant records in the subform given by the relationship through the main form. How do I get this calculation to only calculate on the records in the subform? I clearly have to learn syntax for calculations. I don't know how to specifically point to the subform.
I know my expression "tbl_JM" is the problem, I just don't know how to (syntax) point to the specific subform I am trying to count the records in.
The value itself is represented in a text box within the subform and is visible for every record in the subform.
Thanks for all possible help, even a good link to a tutorial on expression builder syntax would be nice.
I am quite new to Access and have a problem I hope someone can help me with.
I have a main form called frm_SAMPLE and in this form I have added a subform called frm_JM_subform. The subform is a continuous form linked through a relationship sample_id <> sample_id. It is a one-to-many relationship, eg. the subform frm_JM_subform contains many records for every record in frm_SAMPLE. The subform frm_JM_subform is based on table tbl_JM and the main form based on a table called tbl_SAMPLES.
I wish to count the number of records in the subform and through a calculation add an incremental index number to every record in the subform, something like the example below:
Nr. Field 1: Field 2:
1 Value 1 Value 2
2 Value 1 Value 2
etc.
The incremental number in the first row is of course not the key as the relationship will decide which records show depending on which record is active in the main form. It is this number I am trying to calculate. Is is this incremental number I wish to show in the subform.
As an example I have watched a youtube instruction video almost solving my problem.
My calculation looks like this:
=DCount("*";"tbl_JM";"JM_id <=" & [JM_id])
The calculation works but the values it returns are based on the whole table (tbl_JM) and not the relevant records in the subform given by the relationship through the main form. How do I get this calculation to only calculate on the records in the subform? I clearly have to learn syntax for calculations. I don't know how to specifically point to the subform.
I know my expression "tbl_JM" is the problem, I just don't know how to (syntax) point to the specific subform I am trying to count the records in.
The value itself is represented in a text box within the subform and is visible for every record in the subform.
Thanks for all possible help, even a good link to a tutorial on expression builder syntax would be nice.