Here is a good rule. It has no exceptions:
Prepositions are always followed by a noun-phrase.
If we want to use a verb after a preposition, it must be a gerund (which functions as a noun). It is impossible to use an infinitive after a preposition. So, for example, we say:
I will call you after arriving at the office.
not I will call after to arrive at the office.
Please have a drink before leaving.
I am looking forward to meeting you.
Do you object to working late?
Tara always dreams about going on holiday.
Notice that you could replace all the above gerunds with "real" nouns:
I will call you after my arrival at the office.
Please have a drink before your departure.
I am looking forward to our lunch.
Do you object to this job?
Tara always dreams about holidays.