There are several Questions in Research Gate which treate this problem. You can search the term "sample size" and researchgate.net to find examples of this. I put these examples:
If the selection of the sample is probabilistic, I advice you to consult books on Sampling Theory, Sampling Techniques, etc. I have also a book in Spanish which treates the sample size calculation.
Ruiz Espejo, Mariano (2013). Exactitud de la Inferencia en Poblaciones Finitas. Bubok. Madrid.