It is essential that you understand what the code is doing - being 'given it' is not enough. The OpenReport action can be filtered so that instead of the report showing all records it shows just a subset of them, or in this case, the record matching the one in your form.
To do this the MainInfoID field on the report has to be matched to the corresponding value on your form - but at present (in line 2 above) you are not supplying the value of the field at all, just a reference to the form itself. You also need to include the value of the control, not a reference to its name, in the filter statement.
Assuming that the control on your form is also called maininfoID, try replacing line 2 with:
- "[maininfoID] = " & Forms!frmtimesheet!maininfoID
or, using the simpler reference to the current form itself available using the Me keyword,
- "[maininfoID] = " & Me!maininfoID
This assumes that your primary key is a number. If it is not a number but is instead a text string, you would need to include the value inside single quotes, like this:
- "[maininfoID] = '" & Me!maininfoID & "'"
Please note that this last example is for text strings only - it will not work at all if the value being matched is a number, so please do not confuse the two forms of the statement!
-Stewart