I would add that it need not be the only opportunity but may simply be out of a desire to go.
It is important also to emphasize that as noted here the norm is that one is not to receive Holy Communion if one has mortal sin:
Catechism:
1385 To respond to this invitation we must prepare ourselves for so great and so holy a moment. St. Paul urges us to examine our conscience: "Whoever, therefore, eats the bread or drinks the cup of the Lord in an unworthy manner will be guilty of profaning the body and blood of the Lord. Let a man examine himself, and so eat of the bread and drink of the cup. For any one who eats and drinks without discerning the body eats and drinks judgment upon himself."218
Anyone conscious of a grave sin must receive the sacrament of Reconciliation before coming to communion.
scborromeo.org/ccc/p2s2c1a3.htm#VI
And for further clarification for readers as to the possibility of some (rather on rare side I would think) exceptions where a person could receive Holy Communion after they committed a mortal sin but before confession–such only under certain very circumscribed circumstances.
As Canon Law notes it must be for a “grave reason” and “there is no opportunity to confess” and the person has the obligation to make an act of perfect contrition which includes the resolve to go to confession as soon as possible (Canon 916 CIC)
But let us return to the main topic of the thread on the confession of venial sins.