Good catch on adding the quotes to the criteria string. I should have checked on that myself.
On adding a second criteria...
A variable only contains what it is assigned. It doesn't get added to. Seems simple, but look again at lines 7 and 8. On line 7, you assign a value to stLinkCriteria. On line 8, you assign another value to stLinkCriteria, wiping out the previous value from line 7. This can be done by concatenating the value of stLinkCriteria with another value and assigning that back to stLinkCriteria.
- stLinkCriteria = stLinkCriteria & " And [project]=" & "'" & Me![project] & "'"
Notice the
And I put before
[project]. That is how you have multiple criteria in a SQL WHERE statement (which is what you are building minus the word WHERE).
However, in this case you can just do it all on one line.
- stLinkCriteria = "[beneficiary]=" & "'" & Me![beneficiary] & "' And [project]=" & "'" & Me![project] & "'"
if you want the line shorter, then use a line continuation character and then make a new line.
- stLinkCriteria = "[beneficiary]=" & "'" & Me![beneficiary] & _
-
"' And [project]=" & "'" & Me![project] & "'"
One quick note about posting questions, we only allow one question per thread. This one was kind of one the edge of being a new question, but about the same problem so I did answer it here. Just for future reference, try to keep each thread on one focus. New questions can be posted in a new thread. It makes it easier for answers to be found in a search.